Skip to content

R Color Reference Sheet

2013 April 17
by Michał

R has a built-in collection of 657 colors that you can use in plotting functions by using color names. There are also various facilities to select color sequences more systematically:

  • Color palettes and ramps available in packages RColorBrewer and colorRamps.
  • R base functions colorRamp and colorRampPalette that you can use to create your own color sequences by interpolating a set of colors that you provide.
  • R base functions rgb, hsv, and hcl that you can use to generate (almost) any color you want.

When producing data visualizations, the choice of proper colors is often a compromise between the requirements dictated by the data visualisation itself and the overall style and color of the article/book/report that the visualization is going to be an element of. Choosing an optimal color palette is not so easy and its handy to have some reference. Inspired by a this sheet by Przemek Biecek I created a variant of an R color reference sheet showing different ways in which you can use and call colors in R when creating visualizations. The sheet fits A4 paper (two pages). On the first page it shows a matrix of all the 657 colors with their names. On the second page, on the left, all palettes from RColorBrewer package are displayed. On the right, selected color ramps available in base R (base package grDevices) and in the contributed package colorRamps. Miniatures below:

rcolorsheet-0 rcolorsheet-1

You can download the sheet as PDF from here.

Below is a gist with the code creating the sheet as a PDF “rcolorsheet.pdf”. Instead of directly reusing the Przemek’s code I have rewritten the parts that produce the first page (built-in color names) and the part with the ramps using the image function. I think it is much simpler, less low-level for-looping and a bit more extensible. For example, it is easy to extend the collection of color ramps by providing just additional function name in the form packagename::functionname to the funnames vector (any extra package would have to be loaded at the top of the script).

2 Responses leave one →
  1. April 18, 2013

    Note that the “colorspace” package also provides a collection of color palettes based on the HCL model. Many of these are rather similar to the ColorBrewer palettes but provide explicit formulas for construction and hence leave more room to play around with the palettes. Unlike the palettes from the colorRamp package, these are balanced with respect to their perceptual properties. See the corresponding manuscript ( for more details. And also explore the choose_palette() GUI which allows to explore palettes on a wide range of (artificial) data examples and for color-blind viewers etc.

    • April 18, 2013

      Hi Achim. Thanks. I was not familiar with “colorspace”, I’ll have a look at it.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS