add_wordmarks
add_wordmarks(target: Any, *args: Any, **kwargs: Any) -> Any
Add team wordmarks to a plot or table of any supported library.
Routes to the adapter for target's library (matplotlib, plotnine, Plotly, Altair, great_tables, ...) and returns
the object that was drawn on: target itself when the library mutates in place, a new object otherwise. Plots and
tables take different arguments. A plot (matplotlib, plotnine, Plotly, Altair, Bokeh, HoloViews, folium and pygal)
takes x, y and teams, and a height that is a fraction of the plot height. A great_tables GT
takes columns and a height in pixels, with no alpha or variant (see
sdvplot.great_tables.gt_sdv_wordmarks).
Arguments
| Name | Description |
|---|---|
target | The plot or table object. Its type picks the adapter. |
*args | Passed to the adapter. For a plot: x, y (positions in the target's own coordinates) and teams (the team values to draw), in that order. For a table: columns (the columns whose cells become marks). |
**kwargs | Passed to the adapter: league (the SDV league key) and season (for a plot one season or one per team, for a table one season). For a plot, also height (a fraction of the plot height, in (0, 1]), alpha (opacity, 0 to 1) and variant (a mark variant, as in logo_url); for a table, height is in pixels (default 30). |
Returns
object — The drawn-on plot or table: target itself, or the new object the adapter built.
Raises
UnsupportedTargetError: (a TypeError) If no adapter is registered fortarget's library, or the adapter cannot draw on this kind oftarget(a pygal Bar chart, a folium FeatureGroup).OptionalDependencyError: (a ModuleNotFoundError) If the adapter's optional extra is not installed, or a mark a raster adapter draws is an SVG and thesvgextra is not installed.TypeError: If the adapter does not take an argument given (a table takes nox,y,alpha).InputError: (a ValueError) If a value is out of range: a plotheightoutside (0, 1] oralphaoutside [0, 1], or a tableheightbelow 1 pixel (a fraction such as 0.1 is a plot's unit, not a table's); orleague,id_system,variantorseasonis not one sdvplot knows.ValueError: If the adapter's own checks fail (inputs of different lengths, an axis it cannot place on); its page lists them.UnresolvedTeamError: (a ValueError) If a table adapter is givenstrict=Trueand a value does not resolve.OfflineError: If a download the adapter needs (the logo manifest, a mark's image, a headshot) fails and no cached copy exists: a DownloadError (also an OSError) for an HTTP error status, an IntegrityError for a file that does not match the manifest's sha256. Which downloads an adapter makes is on its page.UnsafeDownloadError: (an OSError) If a download is refused: larger than the byte cap, past the deadline, or redirected away from https.
Example
import matplotlib.pyplot as plt
import sdvplot
fig, ax = plt.subplots()
sdvplot.add_wordmarks(ax, [0.5], [0.5], ["KC"], league="nfl", height=0.1)