Using RColorBrewer from base R.



This post shows how to build a palette with RColorBrewer and use it in a base R chart.

Base R color Section About line chart

The RColorBrewer package offers about 25 different color palettes for R. To build a color palette using it, use the brewer.pal() function.

Note: if you need more than 7 colors, read this post.

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)

# Build a color palette, 5 colors coming from the BuPu color palette"
coul <- brewer.pal(5, "BuPu") 

# Build a pie chart with it
pie(rep(1, length(coul)), col = coul , main="") 

Related chart types


Ggplot2
Animation
Interactivity
3D
Caveats
Data art



❤️ 10 best R tricks ❤️

👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥