/cetcolor

CET Perceptually Uniform Colour Maps for R

Primary LanguageR

CRAN_Status_BadgeTravis-CI Build Status

CET Perceptually Uniform Colour Maps (colorcet)

The cetcolor package is designed to bring to R the color maps created by Peter Kovesi to avoid points of locally high color contrast leading to the perception of false anomalies in your data when there is none. The color maps have been designed to avoid this phenomenon by having uniform perceptual contrast over their whole range.

Sample

# install.packages("devtools")

# Install the package
devtools::install_github("coatless/cetcolor")
# Load the Library
library("cetcolor")

# Get RGB Hexadecimals for graphing
cet_pal(5, name = "blues")
#> [1] "#F1F1F1" "#C0D3EB" "#93B5DD" "#7197C1" "#3B7CB2"

# Sample use with ggplot2
library("ggplot2")

ggplot(faithfuld, aes(waiting, eruptions)) +
  geom_raster(aes(fill = density)) +
  theme_bw() + theme(panel.grid=element_blank()) -> g

library("gridExtra")

grid.arrange(
  g + scale_fill_gradientn(colours = cet_pal(5, name = "fire")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "inferno")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "blues")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "kgy")),
  ncol = 2, nrow = 2
)

# Show a panel of possible values (no-nicknames)
display_cet_all()

References

CET

R Color Palettes

  • viridis
    • Provides MATLAB perceptually uniform colormaps in a manner that is similar to this package.
  • RColorBrewer
    • Function interface naming, e.g. cet_pal(n, name), and color map displays.
  • scales and [ggplot2](https://github.com/tidyverse/ggplot2/blob/f6f9f9de41c48382c70cbccc253db198e3cdc128/R/scale-brewer.r) - Proper ways to interface color palettes withggplot2as shown forRColorBrewer`.

Future

  • Allow for n > 256.
  • Provide hooks for ggplot2 gradient and discrete scales
  • Port over the Peter's generation code from Julia / MATLAB to R.