Skip to content

A ggplot color palette featuring the best band in the world: Pearl Jam.

License

Notifications You must be signed in to change notification settings

jorgeluis8ar/PeaRlJam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PeaRlJam

Build Status

Render README

pkgdown

R build status

A ggplot color palette featuring the best band in the world: Pearl Jam. I used all the 11 studio albums covers from the band to compile a color palette from each album the band has realeased. I used studio albums rather than compilations or redux albums but later updates will consider all covers art work.

Instalation

The realeased version of PeaRlJam could be installed by running the following command:

remotes::install_github("jorgeluis8ar/PeaRlJam")

and loaded with:

library(PeaRlJam)

Extracting colors from album covers

I extract the colors out of the album's covers by using two packages. The first is colorfindr. The package allows to read and abstract the image information and stored by using the function get_colors. This information is then passed trough the function make_palette and we obtain our final colors. Note that I only use 15 colors and that the function have other parameters to fine tune your colors. I the use the package purrr and use the fuction map to help me create a list of the colors for all my album covers. The final colors are in HEX format, but the get_colors function allows the user to abstract other color schemes.

images <- list.files(path = directory) %>% paste0(directory,'/',.)
list_colors <- map(images,function(x) get_colors(img = x) %>% make_palette(n = 15))

For further information on color extraction see this geniully awesome repo.

Examples

scale_color_pearl() - Backspacer palette

I explore firsly the mpg dataset to analyze the City Miles per Gallon (CMPG) comparison across engine displacement using our first color palette : Backspacer album cover. The following code is used to replicate the graph:

ggplot(mpg,aes(x = displ,y = cty, color = class)) + geom_point(size = 3) +
  scale_color_pearl(palette = "Backspacer") +
  labs(x = "Engine displacement (Ltrs)",
       y = "City miles per gallon (CMPG)",
       color = "Type of car",
       title = "CMPG comparisson across engine displacement",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: Backspacer")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     legend.box="vertical",
                     legend.margin=margin())

drawing

scale_color_pearl() - Pearl Jam palette

Here I change the palette to see the pros and cons of each one. In this case I use Pearl Jam album cover. The following code is used to replicate the graph:

ggplot(mpg,aes(x = displ,y = cty, color = class)) + geom_point(size = 3) +
  scale_color_pearl(palette = "Pearl Jam") +
  labs(x = "Engine displacement (Ltrs)",
       y = "City miles per gallon (CMPG)",
       color = "Type of car",
       title = "CMPG comparisson across engine displacement",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: Pearl Jam")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     legend.box="vertical",
                     legend.margin=margin())

drawing

scale_fill_pearl() - No Code palette

We can now use the palettes will the fill option. Using the mpg database and the No Code album cover it's posible to produce the following graph:

ggplot(mpg, aes(manufacturer, fill = manufacturer)) +
  geom_bar(color = "black", size = 0.25) + scale_fill_pearl(palette = "No Code") +
  labs(x = "Car manufacturer",
       y = "Count of observations",
       color = "Manufacturer",
       title = "Observations per car manufacturer",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: No Code")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     # legend.position = "bottom",
                     legend.box="vertical",
                     legend.margin=margin())

drawing

scale_fill_pearl() - Yield palette

The same graph with a different palette. In this case I use the Yield album cover to reproduce the previous graph:

ggplot(mpg, aes(manufacturer, fill = manufacturer)) +
  geom_bar(color = "black", size = 0.25) + scale_fill_pearl(palette = "Yield") +
  labs(x = "Car manufacturer",
       y = "Count of observations",
       color = "Manufacturer",
       title = "Observations per car manufacturer",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: Yield")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     # legend.position = "bottom",
                     legend.box="vertical",
                     legend.margin=margin())

drawing

scale_fill_pearl() with discrete color aesthetic- Gigaton and Lightning Bolt palettes

For this section I use the famous and renowed iris database. The following graphs use the graphs Gigaton (album cover) and Lightning Bolt (album cover) palettes respectevely.

ggplot(data = iris,aes(x = Sepal.Length, y =Sepal.Width, color = Species)) + geom_point(size = 3)+
  scale_color_pearl(discrete = T,palette = "Gigaton") +
  labs(x = "Sepal Length",
       y = "Sepal Width",
       color = "Specie",
       title = "Relationship between Sepal length and Sepal width",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: Gigaton")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     legend.box="vertical",
                     legend.margin=margin())

drawing

ggplot(data = iris,aes(x = Sepal.Length, y =Sepal.Width, color = Species)) + geom_point(size = 3)+
  scale_color_pearl(discrete = T,palette = "Lightning Bolt") +
  labs(x = "Sepal Length",
       y = "Sepal Width",
       color = "Specie",
       title = "Relationship between Sepal length and Sepal width",
       caption = "Color palettes based on PeaRlJam Package",
       subtitle = "PeaRlJam color palette: Lightning Bolt")+
  theme_bw() + theme(plot.title = element_text(hjust = 0.5,size = 13),
                     plot.subtitle = element_text(hjust = 0.5,size = 13),
                     axis.title = element_text(size = 12),
                     legend.text = element_text(size = 10),
                     legend.title = element_text(size = 11),
                     legend.box="vertical",
                     legend.margin=margin())

drawing

Available palettes

The following tables resumes all the posible palettes the package PeaRlJam takes into account.

Album Name Palette Name Number of colors Colors generated with Link
Gigaton Gigaton 15 function get_colors + make_palette Album's page
Lightning Bolt Lightning Bolt 15 function get_colors + make_palette Album's page
Backspacer Backspacer 15 function get_colors + make_palette Album's page
Pearl Jam Pearl Jam 15 function get_colors + make_palette Album's page
Riot Act Riot Act 15 function get_colors + make_palette Album's page
Binaural Binaural 15 function get_colors + make_palette Album's page
Yield Yield 15 function get_colors + make_palette Album's page
No Code No Code 15 function get_colors + make_palette Album's page
Vitalogy Vitalogy 15 function get_colors + make_palette Album's page
Vs. Vs. 15 function get_colors + make_palette Album's page
Ten Ten 15 function get_colors + make_palette Album's page

Related Packages

There are several extensios to this type of packages in R. But I mainly drew inspiration on the taylorRswift package by asteves. TO my extent this is the first ever packages to use Pearl Jam's album cover art to create color palette extensions. Related packages are:

About

A ggplot color palette featuring the best band in the world: Pearl Jam.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages