The default scale for ggplot2 for 13 or more colours does not provide a high degree of visual differentiation. In addition, the longest of the brewer scales ends at 12 categories (Set3).
Can you recommend a colour scale that would be visually useful for 13 or more categories?
Reproducible example:
dat <- data.frame(value=rnorm(100),
category=sample(letters[1:13],100,replace=T),
other=sample(letters[1:5],100,replace=T))
# Default Scale
ggplot(dat, aes(other,value,color=category)) +
geom_point(size=6) +
coord_flip()
# Brewer Scale // notice the blank at the end!
ggplot(dat, aes(other,value,color=category)) +
geom_point(size=6) +
coord_flip() +
scale_color_brewer(palette="Set3")
Note: facetting is not an option in my case (client doesn't like it, go figure)
You could use colorRampPalette
and scale_colour_manual
to fudge a 13th category.
set3 <- colorRampPalette(brewer.pal('Set3',n=12))
ggplot(dat, aes(other,value,color=category)) +
geom_point(size=6) +
coord_flip() +
scale_color_manual(values = setNames(set3(13), levels(dat$category)))
This will break down, in that the colours will not be nicely distinguishable if you set the required numbers too high.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With