Palette with more colours

2,114 views
Skip to first unread message

elegans

unread,
Jun 6, 2013, 9:39:16 AM6/6/13
to ggp...@googlegroups.com
Hi,
I am using scale_fill_brewer(palette="Set1") to generate different colours for my categories.  I have a large number of categories which seem to be greater than the colours present in the palette.  Is there a palette that has many colours eg > 20 that I can use? 

Thanks

Chris Neff

unread,
Jun 6, 2013, 9:54:13 AM6/6/13
to elegans, ggplot2
There is no palette of 20 colors that will be very distinguishable.  I would suggest figuring out some better way to display the data, it is probably to crowded to be looking at that much at once.



--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

elegans

unread,
Jun 6, 2013, 10:56:46 AM6/6/13
to ggp...@googlegroups.com, elegans
What is the name of the palette with the biggest number of colours I can use then?

Chris Neff

unread,
Jun 6, 2013, 11:10:41 AM6/6/13
to elegans, ggplot2
I mean, you *can* make palettes with > 20 colors, but telling the difference between all colors will be very hard.  If you want to stick something hand curated like the ColorBrewer palettes, "Set3" would give you 12 colors.  Check out http://colorbrewer2.org/

Nick

unread,
Jun 6, 2013, 1:10:33 PM6/6/13
to ggp...@googlegroups.com
I think Chris is right about >20 colors being too hard to distinguish between but if you really wanted to you can make your own color palette of whatever size by using scale_fill_manual(). See the link below under palettes manually define:

Dennis Murphy

unread,
Jun 6, 2013, 2:54:54 PM6/6/13
to elegans, ggplot2
I agree with the other respondents regarding the distinguishability of
color differences when you have a palette with a large number of
colors, but if you insist, you could look into the colorRampPalette()
function, several of the predefined palette functions (e.g.,
rainbow(), topo.colors(), terrain.colors()) and the colorspace
package...and then confirm the warning :)

Here is a toy example for illustration:

library(ggplot2)
qplot(LETTERS[1:5], geom = "bar", fill = LETTERS[1:5]) +
coord_polar() + scale_fill_manual(values = rainbow(5))

qplot(LETTERS[1:25], geom = "bar", fill = LETTERS[1:25]) +
coord_polar() + scale_fill_manual(values = rainbow(25))

# Same idea, different palette
qplot(LETTERS[1:25], geom = "bar", fill = LETTERS[1:25]) +
coord_polar() +
scale_fill_manual(values = colorRampPalette(c("navy", "yellow"))(25))

Dennis

eipi10

unread,
Jun 7, 2013, 2:31:47 PM6/7/13
to ggp...@googlegroups.com, elegans
Just to add one more nuance to Dennis's example: Despite the difficulty of distinguishing small differences between large numbers of colors, if you're set on using a large number, adding a third color to the colorRampPalette function might make the colors a bit more distinguishable, though perhaps harder to interpret if the categories are ordered. For example, in Dennis's example, you could do "values=colorRampPalette(c("red", "navy", "yellow"))(25))". This will give you 25 colors that ramp from red to blue and then from blue to yellow.

Joel
Reply all
Reply to author
Forward
0 new messages