Description Usage Format Details Source Examples
Color palettes for professional sports teams
1 |
A data frame with one row for each professional team and five variables:
the name of the team as they are presented in the teamcolors dataset
the league in which the team plays
the team's primary color
the team's secondary color
the team's tertiary color
the team's quaternary color
the team's division
the team's location, not standardized
the team's mascot
the name of the team as they are presented on the sportslogos website
URL to the team's logo, hosted by http://www.sportslogos.net
The colors given are HTML hexidecimal values. See colors
for more information.
http://jim-nielsen.com/teamcolors/, http://www.sportslogos.net, https://teamcolorcodes.com/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | data(teamcolors)
if (require(Lahman) & require(dplyr)) {
pythag <- Teams %>%
filter(yearID == 2014) %>%
select(name, W, L, R, RA) %>%
mutate(wpct = W / (W+L), exp_wpct = 1 / (1 + (RA/R)^2)) %>%
# St. Louis Cardinals do not match
left_join(teamcolors, by = "name")
with(pythag, plot(exp_wpct, wpct, bg = primary, col = secondary, pch = 21, cex = 3))
# Using ggplot2
if (require(ggplot2)) {
ggplot(pythag, aes(x = wpct, y = exp_wpct, color = name, fill = name)) +
geom_abline(slope = 1, intercept = 0, linetype = 3) +
geom_point(shape = 21, size = 3) +
scale_fill_manual(values = pythag$primary, guide = FALSE) +
scale_color_manual(values = pythag$secondary, guide = FALSE) +
geom_text(aes(label = substr(name, 1, 3))) +
scale_x_continuous("Winning Percentage", limits = c(0.3, 0.7)) +
scale_y_continuous("Expected Winning Percentage", limits = c(0.3, 0.7)) +
coord_equal()
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.