Skip to content

sdvplot 0.1.1

Latest

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 approximations).

Fixed

  • The surfaces cookbook's soccer shot map (§9) placed ESPN shots at twice their distance from goal (ESPN's
    field_position_x is 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 a TypeError that named
    resolve() though the bad value was x. A container sdvplot cannot read now raises a TypeError that names no one
    function: expected a scalar, list, tuple, range, numpy array or a pandas/polars Series, got dict.
  • NHL WIN is 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 VALLEY and RGV resolve in college football (ESPN's teams list omits UT Rio Grande
    Valley, 292; its per-team endpoint's RGV is now in data-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) and USI (Southern Indiana, 88) in mbb, MERC (Mercyhurst,
    2385) and SFPA in wbb, and with them sdvplotR's keys for those teams. tools/fetch_sources.py reads them from
    ESPN's Core API per season (ESPN_CORE_TEAMS) into data-raw/espn_abbrs.csv.
    teams() shows that code as abbr where ESPN's teams lists give none, as for UTRGV (RGV) and college
    baseball's Loras (LOR): eight teams had a null abbr.
  • sdvplotR's conference names draw the conference's logo again: logo_url("Southeastern Conference", "cfb") is
    logo_url("SEC", "cfb"), logo_url("B10", "mbb") is logo_url("Big Ten", "mbb"), and so for the other keys
    sdvplotR's clean_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's MAC is still
    Macalester; resolve("Mid-American Conference", "cfb") no longer gives Macalester (it went through sdvplotR's
    MAC canon): it is None, and its logo is the conference's.
  • gt_tiers no longer writes two alt attributes on an image under great_tables 1.1, whose fmt_image adds an
    empty alt="": the image's alt text replaces it.

Full changelog: https://github.com/sportsdataverse/sdvplot/blob/v0.1.1/CHANGELOG.md