Skip to content

Releases: sportsdataverse/sdvplot

sdvplot 0.1.1

Choose a tag to compare

@saiemgilani saiemgilani released this 26 Oct 04:35
fc6c77a

Added

  • sdvplot.pydeck (new [pydeck] extra): deck.gl layer props for pydeck, the same as sdvplot-js's ./deckgl builds
    (held to one shared fixture). logo_icon_layer draws team logos at points (an IconLayer of auto-packed logo
    icons), pass_arc_layer draws 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), and surface_layer draws a
    sportypy rink, pitch, court or field as a PolygonLayer in the surface's own coordinates. The props are plain dicts
    (pydeck.Layer(**props)); deck() builds a pydeck.Deck fitted 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=) returns classes, style and a scoped css string
    (with a Google Fonts import) that styles an itables.show table like any of the 122 surveyed themes.
  • sdvplot.plottable.plottable_sdv_theme(name, mode=) returns the plottable.Table keywords (text, dividers, stripes) for
    any of the 122 surveyed themes, plus a facecolor to 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() and sdv_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 by tools/gen_gt_shortcuts.py.
  • reactable_sdv_theme(name, mode=) accepts every registry theme, and the new reactable_sdv_args(name, mode=) returns
    the Reactable keywords (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 (its include_conferences):
    the 89 college conferences of cfb, mbb and wbb and the AFC, NFC and NFL, with program "conference" or "league",
    the conference's short name as team_id and abbr, cbbplotR's colors (color_source "cbbplotR") and the
    conference_id the league's teams carry. The default lists teams only, and resolve() and palette() never
    answer a conference key, so no existing call changes.
  • Conference and league logos from the archive (sdvplotR's logo_marks for 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's MAC is still Macalester, and resolve() 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.py conference_mark_aliases, from the new
    data-raw/manifest_conferences.csv snapshot). All 92 rows have a primary mark, as sdvplotR's 92 do.
  • Headshots by the league's own player id: id_system="league" (sdvplotR's id_type = "league") on headshot_url
    and every headshot helper (add_headshots on 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 Stats PERSON_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
    an InputError naming the ones that have them, and a DownloadError from 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_sdv and scale_fill_sdv take alpha=, an opacity applied to the team colors
    (sdvplotR's alpha); na_value is drawn as given. scale_colour_sdv is the British alias sdvplotR and plotnine
    both ship.
  • gt_merge_stack_team_color takes background=, 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_tiers takes alt=, a function from the image paths or URLs to their alt text. By default a logo the archive
    knows (any logo_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, with flip for teams attacking opposite ends. The port of
    sdvplotR's sdv_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 court surface("fiba") draws, in meters, with the -1,-1 free throws as
    null. The default "nba" is unchanged, byte for byte. Matched to sdvplotR's sdv_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's scale_x_sdv_headshots() / scale_y_sdv_headshots() and element_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
    UnsupportedTargetError as before. sdvplot.typing.AxisMarkType is the Literal of 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/sporty and @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
    frame pitch_coords() returns; pitch_updates still overrides it key by key.
  • gt_merge_stack_team_color keeps 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 (#737373 on 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, or None not to dim.
  • team_tiers (matplotlib and plotnine) takes variant=, 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. Pass variant="default" for the old look (sdvplotR's), or
    any variant add_logos takes.
  • great_tables 1.1 is supported. Its data_color now interpolates in CIELAB, as R gt and scales::col_numeric do,
    so gt_color_ranks fills match sdvplotR's exactly under it; gt_color_pills, gt_percentile_bar and the
    gt_legend_continuous steps now draw great_tables' own gradient, so they stay equal to data_color cells on every
    version (CIELAB from 1.1, sRGB before) and match sdvplotR's colors from 1.1 (they were sRGB approx...
Read more

sdvplot 0.1.0

Choose a tag to compare

@saiemgilani saiemgilani released this 05 Oct 18:11
ff49ede

First release of sdvplot, the SportsDataverse package of team logos, wordmarks, headshots and colors for plots and tables in Python (the counterpart to sdvplotR).

pip install sdvplot              # core
pip install "sdvplot[mpl]"       # with matplotlib
  • Team identity for 28 leagues: resolve abbreviations, ESPN/league ids and historical codes by season, with team colors, logos and wordmarks from a dated logo archive.
  • Adapters for matplotlib, seaborn, plotnine, plotly, altair, bokeh, holoviews, folium and pygal, plus great_tables, reactable and plottable table helpers and surface() rinks, courts and fields.
  • A frozen public API: keyword-only options, sdvplot.SdvplotError subclasses for every failure, and an offline-friendly disk cache.

Docs, tutorials, cookbooks and the gallery: https://sdvplot.sportsdataverse.org
Full notes, including migrating from the git pre-release: CHANGELOG