Scientific Journal and Sci-Fi Themed
Color Palettes for ggplot2

Nan Xiao <https://nanx.me>
Miaozhu Li <http://miaozhu.li>

2018-05-13

1 Introduction

My eyes were finally opened and I understood nature.

I learned at the same time to love it.

— Claude Monet

ggsci offers a collection of high-quality color palettes inspired by colors used in scientific journals, data visualization libraries, science fiction movies, and TV shows. The color palettes in ggsci are available as ggplot2 scales. For all the color palettes, the corresponding scales are named as:

We also provided aliases, such as scale_colour_palname() for scale_color_palname(). All available color palettes are summarized in the table below.

Name Scales Palette Types Palette Generator
NPG scale_color_npg() scale_fill_npg() "nrc" pal_npg()
AAAS scale_color_aaas() scale_fill_aaas() "default" pal_aaas()
NEJM scale_color_nejm() scale_fill_nejm() "default" pal_nejm()
Lancet scale_color_lancet() scale_fill_lancet() "lanonc" pal_lancet()
JAMA scale_color_jama() scale_fill_jama() "default" pal_jama()
JCO scale_color_jco() scale_fill_jco() "default" pal_jco()
UCSCGB scale_color_ucscgb() scale_fill_ucscgb() "default" pal_ucscgb()
D3 scale_color_d3()
scale_fill_d3()
"category10" "category20" "category20b" "category20c" pal_d3()
LocusZoom scale_color_locuszoom() scale_fill_locuszoom() "default" pal_locuszoom()
IGV scale_color_igv() scale_fill_igv() "default"
"alternating"
pal_igv()
UChicago scale_color_uchicago() scale_fill_uchicago() "default"
"light"
"dark"
pal_uchicago()
Star Trek scale_color_startrek() scale_fill_startrek() "uniform" pal_startrek()
Tron Legacy scale_color_tron() scale_fill_tron() "legacy" pal_tron()
Futurama scale_color_futurama() scale_fill_futurama() "planetexpress" pal_futurama()
Rick and Morty scale_color_rickandmorty() scale_fill_rickandmorty() "schwifty" pal_rickandmorty()
The Simpsons scale_color_simpsons() scale_fill_simpsons() "springfield" pal_simpsons()
GSEA scale_color_gsea() scale_fill_gsea() "default" pal_gsea()
Material Design scale_color_material() scale_fill_material() "red" "pink"
"purple" "deep-purple"
"indigo" "blue"
"light-blue" "cyan"
"teal" "green"
"light-green" "lime"
"yellow" "amber"
"orange" "deep-orange"
"brown" "grey"
"blue-grey"
pal_material()

2 Discrete Color Palettes

We will use scatterplots with smooth curves, and bar plots to demonstrate the discrete color palettes in ggsci.

library("ggsci")
library("ggplot2")
library("gridExtra")

data("diamonds")

p1 = ggplot(subset(diamonds, carat >= 2.2),
       aes(x = table, y = price, colour = cut)) +
  geom_point(alpha = 0.7) +
  geom_smooth(method = "loess", alpha = 0.05, size = 1, span = 1) +
  theme_bw()

p2 = ggplot(subset(diamonds, carat > 2.2 & depth > 55 & depth < 70),
       aes(x = depth, fill = cut)) +
  geom_histogram(colour = "black", binwidth = 1, position = "dodge") +
  theme_bw()

2.1 NPG

The NPG palette is inspired by the plots in the journals published by Nature Publishing Group:

2.2 AAAS

The AAAS palette is inspired by the plots in the journals published by American Association for the Advancement of Science:

2.3 NEJM

The NEJM palette is inspired by the plots in The New England Journal of Medicine:

2.4 Lancet

The Lancet palette is inspired by the plots in Lancet journals, such as Lancet Oncology:

2.5 JAMA

The JAMA palette is inspired by the plots in The Journal of the American Medical Association:

2.6 JCO

The JCO palette is inspired by the the plots in Journal of Clinical Oncology:

2.7 UCSCGB

The UCSCGB palette is from the colors used by UCSC Genome Browser for representing chromosomes. This palette has been intensively used in visualizations produced by Circos.

2.8 D3

The D3 palette is from the categorical colors used by D3.js (version 3.x and before). There are four palette types (category10, category20, category20b, category20c) available.

2.9 LocusZoom

The LocusZoom palette is based on the colors used by LocusZoom.

2.10 IGV

The IGV palette is from the colors used by Integrative Genomics Viewer for representing chromosomes. There are two palette types (default, alternating) available.

2.11 UChicago

The UChicago palette is based on the colors used by the University of Chicago. There are three palette types (default, light, dark) available.

2.12 Star Trek

This palette is inspired by the (uniform) colors in Star Trek:

2.13 Tron Legacy

This palette is inspired by the colors used in Tron Legacy. It is suitable for displaying data when using a dark theme:

2.14 Futurama

This palette is inspired by the colors used in the TV show Futurama:

2.15 Rick and Morty

This palette is inspired by the colors used in the TV show Rick and Morty:

2.16 The Simpsons

This palette is inspired by the colors used in the TV show The Simpsons:

3 Continuous Color Palettes

We will use a correlation matrix visualization (a special type of heatmap) to demonstrate the continuous color palettes in ggsci.

library("reshape2")

data("mtcars")
cor = cor(unname(cbind(mtcars, mtcars, mtcars, mtcars)))
cor_melt = melt(cor)

p3 = ggplot(cor_melt,
            aes(x = Var1, y = Var2, fill = value)) +
  geom_tile(colour = "black", size = 0.3) +
  theme_bw() +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank())

3.1 GSEA

The GSEA palette (continuous) is inspired by the heatmaps generated by GSEA GenePattern.

3.2 Material Design

The Material Design color palettes are from the material design color guidelines.

We generate a random matrix first:

Plot the matrix with the 19 material design color palettes:

From the figure above, we can see that even though an identical matrix was visualized by all plots, some palettes are more preferrable than the others because our eyes are more sensitive to the changes of their saturation levels.

4 Non-ggplot2 Graphics

To apply the color palettes in ggsci to other graphics systems (such as base graphics and lattice graphics), simply use the palette generator functions in the table above. For example:

mypal = pal_npg("nrc", alpha = 0.7)(9)
mypal
## [1] "#E64B35B2" "#4DBBD5B2" "#00A087B2" "#3C5488B2" "#F39B7FB2" "#8491B4B2"
## [7] "#91D1C2B2" "#DC0000B2" "#7E6148B2"
library("scales")
show_col(mypal)

You will be able to use the generated hex color codes for such graphics systems accordingly. The transparent level of the entire palette is easily adjustable via the argument "alpha" in every generator or scale function.

5 Discussion

Please note some of the palettes might not be the best choice for certain purposes, such as color-blind safe, photocopy safe, or print friendly. If you do have such considerations, you might want to check out color palettes like ColorBrewer and viridis.

The color palettes in this package are solely created for research purposes. The authors are not responsible for the usage of such palettes.