Skip to content

Latest commit

 

History

History
203 lines (139 loc) · 4.6 KB

README.md

File metadata and controls

203 lines (139 loc) · 4.6 KB

CRAN_Status_Badge Travis build status

NBA Palettes

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.

Installation

CRAN

Package can be installed from cran with the following:

install.packages('nbapalettes')

The dev version of the package can be installed from github with the following:

devtools::install_github('murrayjw/nbapalettes')

Usage

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

Palettes

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).

Denver Nuggets

The structure of the palette names is: teamname_jerseytype. For example to see the Utah Jazz city colors for this season:

nba_palette("nuggets_city2")

Utah Jazz

nba_palette("jazz_city")

Toronto Raptors

nba_palette("raptors_original")

nba_palette("raptors_military")

Miami Heat

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()

More examples

nba_palette("bucks_earned")

nba_palette("bucks_city2")

nba_palette("bobcats")

nba_palette("grizzlies_retro")

nba_palette("grizzlies_retro", 'continuous', n = 100)

nba_palette("sixers_city")

nba_palette("warriors")

nba_palette("warriors_00s")

Combining Palettes

Palettes can be combined by passing a vector of palette names

nba_palette(c("warriors", "warriors_00s"))