This package is based on the amazing wesanderson package. It includes color palettes taken from a large variety of NBA jersey colorways. These can be used to Spicy P up your plots. The package currently contains 129 different palettes.
library("nbapalettes")
# See available palettes
available_palettes()
#> # A tibble: 129 x 3
#> teams palette_names palette_colors
#> <chr> <chr> <chr>
#> 1 bobcats bobcats #0C2340, #418FDE, #1B365D, #E35205, #888B8D
#> 2 bobcats bobcats_original #F9423A, #1B365D, #8D9093, #010101
#> 3 blazers blazers #E13A3E, #C4CED4, #000000
#> 4 blazers blazers_statement #C8102E, #010101, #373A36
#> 5 blazers blazers_city #fea30c, #203b7e, #0881c6, #cf152d, #df4826
#> 6 blazers blazers_city2 #2E2E2E, #140C0B, #C72830, #EC3036
#> 7 bucks bucks #00471B, #EEE1C6, #0077C0, #000000
#> 8 bucks bucks_earned #7AC043, #00713D, #014711, #CB0423, #D7D7D7, #FFFF~
#> 9 bucks bucks_00s #AC1A2F, #274E37, #95999D
#> 10 bucks bucks_retro #2C5234, #00843D, #6CC24A, #DE7C00, #010101
#> # ... with 119 more rows
The package currently contains 129 palettes based on various NBA jerseys from every current NBA team and a few of former teams (Bobcats, Supersonics, New Orleans Hornets).
The structure of the palette names is: teamname_jerseytype. For example to see the Utah Jazz city colors for this season:
The package comes with team results from the 2020 NBA season (obtained using nbastatR::game_logs()
from the nbastatR package).
library("ggplot2")
library("dplyr")
data(nba_results2020)
nba_results2020 %>%
filter(nameTeam == 'Miami Heat') %>%
ggplot(aes(ptsTeam, fill = factor(isWin))) +
geom_density()+
scale_fill_manual(values = nba_palette("heat"))
nba_palette()
takes an argument type
which can be either continuous or discrete.
pal <- nba_palette("heat_vice", 100, type = "continuous")
nba_results2020 %>%
ggplot(aes(pctFG2Team, pctFG3Team)) +
geom_point(aes(colour = ptsTeam)) +
scale_colour_gradientn(colours = pal) +
theme_minimal()
Palettes can be combined by passing a vector of palette names