#40_colorRampPalette_and_RcolorBrewer

 

The RColorBrewer package is an unavoidable tool to manage colors with R. However, the default palettes give only about 10 different colors. There is a tip for who needs more colors in his graph but still wants to use this useful package.

 


Not what you are looking for ? Make a new search !

[mediatagger]

 


3
Leave a Reply

avatar
2 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
MarkusAngieMatt.0 Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Angie
Guest
Angie

Hi,

this is very helpful but I have one question. How do I get “coul” as my new palette in my ggplot code? I tried:

ggplot(df, aes(x=cond, y=yval, fill=cond)) + geom_bar(stat=”identity”) +
scale_fill_brewer(palette=”coul”)

but got the following error message: “Warning messages: 1: In pal_name(palette, type) : Unknown palette coul”

Many thanks, Angie

Markus
Guest
Markus

use + scale_fill_manual(values=tol21rainbow)

Matt.0
Guest
Matt.0

You can condense this into one line of code; for example to be used with R’s library(pheatmap):

color = colorRampPalette(rev(brewer.pal(n = 7, name = “BuPu”)))(100))