Repository navigation
Added
sdvplot.pydeck(new[pydeck]extra): deck.gl layer props for pydeck, the same as sdvplot-js's./deckglbuilds
(held to one shared fixture).logo_icon_layerdraws team logos at points (anIconLayerof auto-packed logo
icons),pass_arc_layerdraws arcs in team colors (primary at the source, secondary at the target; with
background, 3:1 contrast and ΔE 20 apart through sdvplot-js's team palette, ported), andsurface_layerdraws a
sportypy rink, pitch, court or field as aPolygonLayerin the surface's own coordinates. The props are plain dicts
(pydeck.Layer(**props));deck()builds apydeck.Deckfitted to a surface or a map.sdvplot.perspective(new[perspective]extra, Python 3.11+):perspective_sdv_config(frame, team_col=, league=, plugin=, theme=, mode=)returns a Perspective viewer config (PerspectiveWidget(data, **config)or the JavaScript
restore()) that colors each team with the shared team palette: the Datagrid fills the team column's cells, and a
chart splits by team and colors each team's series. A registry table theme sets the grid's fonts and sign colors.
Number columns get formats (3 decimals, 1 for a percentage, integers plain;formats=overrides).
perspective_logo_column(frame, team_col, league=)adds each team's logo URL, shown as a link.sdvplot.itables.itables_sdv_theme(name, mode=, table_id=)returnsclasses,styleand a scopedcssstring
(with a Google Fonts import) that styles anitables.showtable like any of the 122 surveyed themes.sdvplot.plottable.plottable_sdv_theme(name, mode=)returns theplottable.Tablekeywords (text, dividers, stripes) for
any of the 122 surveyed themes, plus afacecolorto pop and apply to the figure; a font matplotlib cannot find falls
back to its generic family with one warning per family.table_theme_spec()andsdv_table_themes(): resolve and list the 122 surveyed table themes (light and dark).sdvplot.great_tables.gt_theme_source(gt, name, mode=, density=)styles a table like any of the 122 surveyed
themes, plus 20 named shortcuts (gt_theme_datagolf,gt_theme_economist,gt_theme_basketball_reference, ...)
generated bytools/gen_gt_shortcuts.py.reactable_sdv_theme(name, mode=)accepts every registry theme, and the newreactable_sdv_args(name, mode=)returns
theReactablekeywords (theme,striped,highlight,bordered,compact) that match it. reactablefmtr names
are unchanged;mode="dark"on a reactablefmtr theme raises unless the theme is dark already.teams(league, include_conferences=True)lists sdvplotR's conference and league rows (itsinclude_conferences):
the 89 college conferences of cfb, mbb and wbb and the AFC, NFC and NFL, withprogram"conference"or"league",
the conference's short name asteam_idandabbr, cbbplotR's colors (color_source"cbbplotR") and the
conference_idthe league's teams carry. The default lists teams only, andresolve()andpalette()never
answer a conference key, so no existing call changes.- Conference and league logos from the archive (sdvplotR's
logo_marksfor those rows):logo_url("SEC", "cfb"),
logo_url("AFC", "nfl"),logo_url("NFL", "nfl")and every mark helper (marks,logo_image,add_logos,
axis_logos,geom_sdv_logos, the table marks, the web adapters) take a conference or league row's key, with
variant="dark"where the archive has one (16 CFB conferences, the AFC, NFC and NFL) and the usual fallbacks. The
key is read after every team alias, so CFB'sMACis still Macalester, andresolve()still answers no conference:
the rows' only aliases are "mark" aliases, which name the manifest's own conference rows
(level:league:source:entity_id;tools/build_index.pyconference_mark_aliases, from the new
data-raw/manifest_conferences.csvsnapshot). All 92 rows have a primary mark, as sdvplotR's 92 do. - Headshots by the league's own player id:
id_system="league"(sdvplotR'sid_type = "league") onheadshot_url
and every headshot helper (add_headshotson every adapter,geom_sdv_headshots,gt_sdv_headshots,
gt_sdv_cols_label(mark_type="headshot"),reactable_sdv_headshots,plottable.headshot_column) draws an NBA or
WNBA StatsPERSON_ID(what nba_api, hoopR and wehoop return), an MLBAM id or an NHL API id from the league's CDN,
with sdvplotR's URL templates; for the NFL it is the gsis id."espn"stays the default. A league without them is
anInputErrornaming the ones that have them, and aDownloadErrorfrom cdn.nba.com or cdn.wnba.com with a 403
says that those CDNs block datacenter and cloud IPs. surface("fiba")draws a FIBA court (no team yet).sdvplot.plotnine.scale_color_sdvandscale_fill_sdvtakealpha=, an opacity applied to the team colors
(sdvplotR'salpha);na_valueis drawn as given.scale_colour_sdvis the British alias sdvplotR and plotnine
both ship.gt_merge_stack_team_colortakesbackground=, the cell background the bottom line's color is checked against;
the default reads the table's background, so a theme applied first is taken into account.gt_tierstakesalt=, a function from the image paths or URLs to their alt text. By default a logo the archive
knows (anylogo_url) is named by its team and any other image by its file name; the images had no alt text at
all. The alt comes from the cell's value, so a local file (embedded as a data URI) gets a real name.pitch_coords()converts soccer event coordinates from Opta / Stats Perform, Wyscout, StatsBomb, UEFA, Impect,
ESPN and the tracking providers (Tracab, SkillCorner, Second Spectrum, Metrica) to one regulation 105 x 68 m
frame, piecewise-linearly between pitch landmarks, withflipfor teams attacking opposite ends. The port of
sdvplotR'ssdv_pitch_coords(), matched to 1e-12 on every provider.court_coords(provider="euroleague")converts the Euroleague shot frame of sportsdataverse-py's
euroleague_game_points()(coord_x/coord_y: integer centimeters, hoop at the origin, both teams on one basket,
free throws as-1,-1) onto the FIBA courtsurface("fiba")draws, in meters, with the-1,-1free throws as
null. The default"nba"is unchanged, byte for byte. Matched to sdvplotR'ssdv_court_coords(provider = "euroleague")bit for bit on a real Euroleague game (tests/fixtures/euroleague_points_E2025_1.csv).tools/espn_soccer_y_gate.py, the measurement behind the ESPN frame's y direction.axis_logos(..., mark_type="headshot")draws player headshots as axis labels on matplotlib, plotnine, Plotly and
Altair (the port of sdvplotR'sscale_x_sdv_headshots()/scale_y_sdv_headshots()andelement_sdv_headshot()):
the tick labels are read as player ids (id_system"espn", which"auto"means,"gsis"or"league"), each headshot
keeps its own aspect, an unknown id stays as text with one warning, and the adapters without axis logos raise
UnsupportedTargetErroras before.sdvplot.typing.AxisMarkTypeis theLiteralof the three mark types. The
matplotlib y-axis label pad now grows by the widest image's width, so wordmarks and headshots no longer overlap
their tick labels' room. The adapter contract (check_adapter_contract, rule 7) checks the headshot axis too.
Changed
- The README links the JavaScript / TypeScript port, sdvplot-js, now on npm: an npm badge and an Installation note
for@sportsdataverse/sdvplot,@sportsdataverse/sportyand@sportsdataverse/sdvtables, with their docs at
plot.sportsdataverse.org. - The docs site's SDV menu adds cfbseedR and sdvplot-js, and the README's SportsDataverse table adds sdvplot-js, so
the package lists match the other SportsDataverse sites. - polars 2.x is supported: the dependency is
polars>=1.24(was<2). With every optional extra installed,
the full suite (2,343 tests) passes on polars 2.0.0, the same as on 1.44. - numpy is now a core dependency (it was optional, needed only by
pitch_coords()). surface("soccer")draws a regulation 105 x 68 m pitch by default (it drew sportypy's 120 x 90 m maximum), the
framepitch_coords()returns;pitch_updatesstill overrides it key by key.gt_merge_stack_team_colorkeeps the bottom line readable (sdvplotR #55): the team's primary color when it clears
4.5:1 contrast (WCAG AA) on the cell background, else the secondary, else the primary darkened (or lightened, on a
dark table) until it does, so Missouri's gold (1.8:1 on white) reads on a white table and stays gold on a dark one.
An unknown team's grey goes through the same rule.gt_spotlight(dim_color=)defaults to"auto"(sdvplotR #61): the other rows are dimmed to the table's text
blended toward its background until it clears 4.5:1 (#737373on white), instead of the fixed#BBBBBB, which is
1.9:1 on white and barely dimmer than the text on a dark theme. Pass a color to choose it, orNonenot to dim.team_tiers(matplotlib and plotnine) takesvariant=, default"auto": the dark theme now draws the archive's
dark-background logos (the"dark"variant), so dark marks such as the Capitals', the Giants', Penn State's or
Iowa's no longer fade into the near-black background. A team with no dark mark draws its default one, with no
warning; the light theme still draws the default logos. Passvariant="default"for the old look (sdvplotR's), or
any variantadd_logostakes.- great_tables 1.1 is supported. Its
data_colornow interpolates in CIELAB, as R gt andscales::col_numericdo,
sogt_color_ranksfills match sdvplotR's exactly under it;gt_color_pills,gt_percentile_barand the
gt_legend_continuoussteps now draw great_tables' own gradient, so they stay equal todata_colorcells on every
version (CIELAB from 1.1, sRGB before) and match sdvplotR's colors from 1.1 (they were sRGB approximations).
Fixed
- The surfaces cookbook's soccer shot map (§9) placed ESPN shots at twice their distance from goal (ESPN's
field_position_xis a fraction of half the pitch, not of the whole), mirrored the home team's wings, and kept
ESPN's(0, 0)"no location" events. It now scales by 52.5 m, turns the away team half a turn, and drops them. - Coordinates, teams and seasons accept a
range:add_logos(ax, range(1, 8), ...)raised aTypeErrorthat named
resolve()though the bad value wasx. A container sdvplot cannot read now raises aTypeErrorthat names no one
function:expected a scalar, list, tuple, range, numpy array or a pandas/polars Series, got dict. - NHL
WINis season-aware:resolve("WIN", "nhl", season=1990)(and NHL team id 33, and the archive's logos of
those seasons) gives the original Jets' line, today's Utah Mammoth, for the seasons ending 1980-1996, as sdvplotR's
resolve_historical_abbr()does; any other season, or none, gives today's Winnipeg Jets, the relocated Thrashers.
Every season used to give today's Jets, because the NHL stats API files the 1979-96 team under their franchise. UTRGV,TEXAS-RIO GRANDE VALLEYandRGVresolve in college football (ESPN's teams list omits UT Rio Grande
Valley, 292; its per-team endpoint'sRGVis now indata-raw/espn_abbrs.csv).- Six college basketball teams ESPN's teams lists omit resolve by their ESPN abbreviation:
LIN(Lindenwood, 2815),
QUC(Queens, 2511),SFPA(Saint Francis, 2598) andUSI(Southern Indiana, 88) in mbb,MERC(Mercyhurst,
2385) andSFPAin wbb, and with them sdvplotR's keys for those teams.tools/fetch_sources.pyreads them from
ESPN's Core API per season (ESPN_CORE_TEAMS) intodata-raw/espn_abbrs.csv.
teams()shows that code asabbrwhere ESPN's teams lists give none, as for UTRGV (RGV) and college
baseball's Loras (LOR): eight teams had a nullabbr. - sdvplotR's conference names draw the conference's logo again:
logo_url("Southeastern Conference", "cfb")is
logo_url("SEC", "cfb"),logo_url("B10", "mbb")islogo_url("Big Ten", "mbb"), and so for the other keys
sdvplotR'sclean_team_abbrs()maps to a conference or league row ("B1G", "Pac-10", "American Football
Conference"): 275 keys in cfb, mbb, wbb and the NFL, a new internal id system"conference"that only the mark
functions read, after every team alias.resolve()still answers no conference, and CFB'sMACis still
Macalester;resolve("Mid-American Conference", "cfb")no longer gives Macalester (it went through sdvplotR's
MACcanon): it isNone, and its logo is the conference's. gt_tiersno longer writes twoaltattributes on an image under great_tables 1.1, whosefmt_imageadds an
emptyalt="": the image's alt text replaces it.
Full changelog: https://github.com/sportsdataverse/sdvplot/blob/v0.1.1/CHANGELOG.md