Skip to main content
Version: 0.1.1

API reference

Every public function, grouped by what it works with. Each top-level function has a page, and each public submodule (the library adapters, the table helpers, sdvplot.testing and sdvplot.typing) has one page with a section per name. Each gives the signature, the arguments and what the function returns and raises.

Teams​

FunctionWhat it does
resolveCanonical team_id(s) for team values in one league.
suggestUp to n (team_id, name) candidates for a value that did not resolve, best first.
teamsThe bundled team index: one row per (league, team_id), with names, abbreviation, conference and colors.

Colors​

FunctionWhat it does
paletteA {team: "#hex"} dict for a league, ready for seaborn, Plotly, Altair, Bokeh or PyPalettes.
team_colorsOne "#hex" (or None) per team value, in the same container the values came in.

Logos and headshots​

FunctionWhat it does
logo_urlThe CDN URL of a team's logo or wordmark, chosen for the season.
logo_imageThe team's mark as a PIL image (downloaded once, then cached).
marksEvery archived mark for one team, best first.
headshot_urlA headshot URL for one player.

Plots and tables​

FunctionWhat it does
add_logosAdd team logos to a plot or table of any supported library.
add_wordmarksAdd team wordmarks to a plot or table of any supported library.
add_headshotsAdd player headshots to a plot or table of any supported library.
axis_logosReplace an axis' team labels with team logos (or a player axis' with headshots) on any supported library.
surfaceDraw the league's playing surface with sportypy, in a team's colors.
court_coordsConvert stats.nba.com / stats.wnba.com (or Euroleague) shot locations to the court frame sportypy draws.
pitch_coordsConvert soccer event coordinates from any provider's frame to the pitch surface("soccer") draws.
SubmoduleWhat it holds
sdvplot.matplotlibThe matplotlib adapter: logos, wordmarks and headshots on Axes, single-Axes Figures and seaborn grids.
sdvplot.plotnineThe plotnine adapter: logo, wordmark, headshot and image geoms, axis logos, team color scales and reference lines.
sdvplot.plotlyThe Plotly adapter: logos, wordmarks, headshots and axis logos as layout images on a Plotly Figure.
sdvplot.altairThe Altair adapter: logos, wordmarks and headshots as a native Vega-Lite image layer.
sdvplot.bokehThe Bokeh adapter: logos, wordmarks and headshots as one image_url glyph per call on a Bokeh figure.
sdvplot.holoviewsThe HoloViews adapter: a Bokeh plot hook that draws the marks through the Bokeh adapter when the element renders.
sdvplot.foliumThe Folium adapter: logos, wordmarks and headshots as map markers with image icons.
sdvplot.pygalThe pygal adapter: logos, wordmarks and headshots on pygal XY charts, plus team colors as a pygal Style.
sdvplot.pydeckThe pydeck adapter: team logos, team-colored arcs and sportypy playing surfaces as pydeck layer props.
sdvplot.great_tablesgreat_tables helpers (pip install sdvplot[tables]), ported from sdvplotR's gt_* functions.
sdvplot.reactablereactable-py columns (pip install sdvplot[reactable]), ported from sdvplotR's reactable_sdv_* functions, plus reactablefmtr's cell formatters (data bars, color tiles and scales, pills, icons, merged columns, highlights, bubbles).
sdvplot.plottableplottable columns of team logos, wordmarks and player headshots.
sdvplot.itablesitables styling (pip install sdvplot[itables]): a surveyed table theme as DataTables CSS and show options.
sdvplot.perspectivePerspective (pip install sdvplot[perspective], Python 3.11+): team colors, registry fonts and a logo column for a Perspective viewer.

Table themes​

FunctionWhat it does
table_theme_specResolve a surveyed table theme (e.g. datagolf, wikipedia, nejm) by its source name.
sdv_table_themesList the surveyed table themes, optionally only those usable in a mode or in one category.

Housekeeping​

FunctionWhat it does
versionsWhat a bug report needs: the package version, the bundled-index version, and the cached manifest's date.
clear_cacheDelete everything sdvplot has cached (manifest, images, rasters, nflverse, URL images such as headshots).
SubmoduleWhat it holds
sdvplot.testingShared behaviour every adapter must have. Adapter test suites call check_adapter_contract().
sdvplot.typingTypes for annotating code that calls sdvplot: the Literal aliases of its closed argument vocabularies.

Errors and warnings​

Errors and warnings: the warning sdvplot emits and the errors it raises, with what each means.