jcolors intro

version Build Status

jcolors contains a selection of ggplot2 color palettes that I like (or can at least tolerate to some degree)

Installation

Install jcolors from GitHub:

install.packages("devtools")
devtools::install_github("jaredhuling/jcolors")

Access the jcolors color palettes with jcolors():

library(jcolors)

jcolors('default')
##        kelly_green rich_electric_blue        maximum_red 
##          "#29BF12"          "#00A5CF"          "#DE1A1A" 
##     majorelle_blue fluorescent_orange 
##          "#574AE2"          "#FFBF00"

Display all available palettes

Discrete palettes

display_all_jcolors()

Continuous palettes

display_all_jcolors_contin()

Discrete Color Palettes

Use with ggplot2

Now use scale_color_jcolors() with ggplot2:

library(ggplot2)
library(gridExtra)

data(morley)

pltl <- ggplot(data = morley, aes(x = Run, y = Speed,
group = factor(Expt),
colour = factor(Expt))) +
    geom_line(size = 2) +
    theme_bw() +
    theme(panel.background = element_rect(fill = "grey97"),
          panel.border = element_blank(),
          legend.position = "bottom")

pltd <- ggplot(data = morley, aes(x = Run, y = Speed,
group = factor(Expt),
colour = factor(Expt))) +
    geom_line(size = 2) +
    theme_bw() +
    theme(panel.background = element_rect(fill = "grey15"),
          legend.key = element_rect(fill = "grey15"),
          panel.border = element_blank(),
          panel.grid.major = element_line(color = "grey45"),
          panel.grid.minor = element_line(color = "grey25"),
          legend.position = "bottom")

grid.arrange(pltl + scale_color_jcolors(palette = "default"),
             pltd + scale_color_jcolors(palette = "default"), ncol = 2)

grid.arrange(pltl + scale_color_jcolors(palette = "pal2"),
             pltd + scale_color_jcolors(palette = "pal2"), ncol = 2)

Color palettes can be displayed using display_jcolors()

default

display_jcolors("default")

pal2

display_jcolors("pal2")

pal3

display_jcolors("pal3")

pal4

display_jcolors("pal4")

pal5

display_jcolors("pal5")

pal6

display_jcolors("pal6")

pal7

display_jcolors("pal7")

pal8

display_jcolors("pal8")

pal9

display_jcolors("pal9")

pal10

display_jcolors("pal10")

pal11

display_jcolors("pal11")

pal12

display_jcolors("pal12")

rainbow

display_jcolors("rainbow")

More example plots

grid.arrange(pltl + scale_color_jcolors(palette = "pal3"),
             pltd + scale_color_jcolors(palette = "pal3"), ncol = 2)

grid.arrange(pltl + scale_color_jcolors(palette = "pal4"),
             pltd + scale_color_jcolors(palette = "pal4") + 
                 theme(panel.background = element_rect(fill = "grey5")), ncol = 2)

grid.arrange(pltl + scale_color_jcolors(palette = "pal5"),
             pltd + scale_color_jcolors(palette = "pal5"), ncol = 2)