Get a long color palette with RColorBrewer



This post describes how to get a long color palette with R and the RColorBrewer package.

Base R color Section About line chart

The RColorBrewer package is a great tool when it comes to build a color palette with R. However, the default palettes give only about 10 different colors. Here is a tip to get more colors in a graph, still using this useful package. Basically, it relies on the colorRampPalette() function to extand a first palette.

Note: visit this post for a complete list of the available palettes.



# No margin
par(mar=c(0,0,1,0))

# Load RColorBrewer
library(RColorBrewer)

# Classic palette BuPu, with 4 colors
coul <- brewer.pal(4, "PuOr") 

# Add more colors to this palette :
coul <- colorRampPalette(coul)(25)

# Plot it
pie(rep(1, length(coul)), col = coul , main="") 

Related chart types


Ggplot2
Animation
Interactivity
3D
Caveats
Data art



Contact

This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting yan.holtz.data with gmail.com.

Github Twitter