Skip to main content

sdvplot

sdvplot gives Python plots and tables team logos, wordmarks, player headshots and team colors. Logos come from the SportsDataverse logo archive (sdv-assets), and team identity and colors come from an index bundled with the package. It is the Python counterpart to sdvplotR and part of the SportsDataverse.

Install​

pip install git+https://github.com/sportsdataverse/sdvplot

The core needs only narwhals, polars, Pillow, platformdirs and requests. Each extra adds the libraries for one feature:

pip install "sdvplot[mpl] @ git+https://github.com/sportsdataverse/sdvplot"
ExtraAdds
[svg]resvg-py, to rasterize SVG marks in logo_image()
[mpl]matplotlib
[plotnine]plotnine
[plotly]plotly
[altair]altair
[bokeh]bokeh
[holoviews]holoviews
[tables]great_tables
[reactable]reactable
[folium]folium
[surfaces]sportypy and mplsoccer
[plottable]plottable
[pygal]pygal
[all]every extra above

[svg] lets logo_image() rasterize SVG marks. With [mpl], [plotnine], [plotly], [altair], [bokeh], [holoviews], [tables], [folium] or [pygal], add_logos(), add_wordmarks() and add_headshots() draw on that library's plots, tables and maps; axis_logos() works on matplotlib, seaborn, plotnine, Plotly and Altair. [surfaces] is for surface(), and [reactable] and [plottable] add column helpers (sdvplot.reactable, sdvplot.plottable).

Quick example​

import sdvplot

sdvplot.resolve(["LV", "OAK", "Las Vegas Raiders"], "nfl") # ['13', '13', '13']
sdvplot.palette("nfl", teams=["LV", "KC"]) # {'LV': '#000000', 'KC': '#e31837'}
sdvplot.logo_url("OAK", "nfl", season=2010) # the CDN URL of the Oakland-era mark
img = sdvplot.logo_image("LV", "nfl", size=128) # a 128x128 PIL image, cached after the first download
  • resolve() turns any team identifier into the canonical team_id and never guesses.
  • palette() returns a plain {team: "#hex"} dict, keyed by your own values.
  • logo_url() returns the archive URL for a web library. logo_image() returns a decoded image for matplotlib-style libraries.

Learn more​