scale_nfl | R Documentation |
These functions map NFL team names to their team colors in color and fill aesthetics
scale_color_nfl(
type = c("primary", "secondary"),
values = NULL,
...,
aesthetics = "colour",
breaks = ggplot2::waiver(),
na.value = "grey50",
guide = NULL,
alpha = NA
)
scale_colour_nfl(
type = c("primary", "secondary"),
values = NULL,
...,
aesthetics = "colour",
breaks = ggplot2::waiver(),
na.value = "grey50",
guide = NULL,
alpha = NA
)
scale_fill_nfl(
type = c("primary", "secondary"),
values = NULL,
...,
aesthetics = "fill",
breaks = ggplot2::waiver(),
na.value = "grey50",
guide = NULL,
alpha = NA
)
type |
One of |
values |
If |
... |
Arguments passed on to
|
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
breaks |
One of:
|
na.value |
The aesthetic value to use for missing ( |
guide |
A function used to create a guide or its name. If |
alpha |
Factor to modify color transparency via a call to |
library(nflplotR)
library(ggplot2)
team_abbr <- valid_team_names()
# remove conference logos from this example
team_abbr <- team_abbr[!team_abbr %in% c("AFC", "NFC", "NFL")]
df <- data.frame(
random_value = runif(length(team_abbr), 0, 1),
teams = team_abbr
)
ggplot(df, aes(x = teams, y = random_value)) +
geom_col(aes(color = teams, fill = teams), width = 0.5) +
scale_color_nfl(type = "secondary") +
scale_fill_nfl(alpha = 0.4) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.