Skip to contents

A named colour vector for ggplot2::scale_colour_manual() and friends. The R counterpart of sdvplot's palette().

Usage

sdv_color_palette(
  league,
  teams = NULL,
  which = c("primary", "secondary"),
  season = NULL,
  id_system = "auto",
  strict = FALSE
)

Arguments

league

A league key from sdv_leagues(). Required: one abbreviation means different teams in different leagues.

teams

Team identifiers, or NULL for every team.

which

"primary" or "secondary".

season

NULL, one season year, or one per value: picks the team that used a reused code that season. Without one, a reused code means its current holder. Split seasons take their ending year (2021 for 2020-21).

id_system

"auto" (try every id system in priority order) or one id system: "team_id", "espn", "espn_abbr", "nhl", "nflverse", "mlbstats", "nba_api", "hockeytech", "ncaa", "pff", "cricinfo", "cfbd", "bref", "sportsipy", "fangraphs", "yahoo", "kenpom", "torvik", "sdvplotr", "name", or one "auto" never tries because its numbers overlap ESPN's: "nhl_id" (NHL stats API ids), "fox", "cbs", "sports247" (247Sports team and institution ids) or "on3".

strict

If TRUE, a value that does not resolve is an error; otherwise it becomes NA with one warning per call.

Value

A named character vector of hex colours, unresolved teams dropped.

Examples

sdv_color_palette("nfl", c("KC", "BUF", "SF"))
#>        KC       BUF        SF 
#> "#e31837" "#00338d" "#aa0000"