Skip to main content

Function: teamColor()

teamColor(league, o?): ScaleOptions

Defined in: packages/sdvplot/src/plot/scales.ts:48

Plot colour-scale options that colour a team column by team colour. The same scale serves fill and stroke (Plot has one colour scale), so teamFill is this function. Without values the domain is every team_id and abbr; some abbreviations are reused across eras, so pass season to avoid the ambiguity warning. Needs loadLeague(league) first.

Parameters​

league​

"aaf" | "ahl" | "cfb" | "cricket" | "echl" | "mbb" | "milb" | "mlb" | "nba" | "nbagl" | "ncaa_baseball" | "ncaa_mhockey" | "ncaa_softball" | "ncaa_whockey" | "nfl" | "nhl" | "ohl" | "phf" | "pwhl" | "qmjhl" | "soccer" | "ufl" | "usfl" | "ushl" | "wbb" | "whl" | "wnba" | "xfl"

o?​

TeamColorOptions = {}

Returns​

ScaleOptions

Example​

import * as Plot from "@observablehq/plot";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamColor } from "@sportsdataverse/sdvplot/plot";

await loadLeague("nfl");
const wins = [
{ team: "KC", wins: 15 },
{ team: "BUF", wins: 13 },
{ team: "LAC", wins: 11 },
];
Plot.plot({
color: teamColor("nfl", { values: wins.map((w) => w.team) }),
marks: [Plot.barY(wins, { x: "team", y: "wins", fill: "team" })],
});