I used the following code to create a plot using ggplot:
m = ggplot(derv, aes(x=Date, y=derv, colour = Season)) + geom_point()
m2 = m+geom_abline(intercept = 0, slope = 0)
m3 = m2 + geom_abline(intercept = 2.578269274, slope = 0)
m3 = m3 + geom_abline(intercept = -1.4242559021, slope = 0)
This plot looks beautiful but for some intervals such as 2010sp and 2010au, it is hard for me to tell when the color changed. So I want to change the color scheme of this plot.
and I have tried the following code:
m3+scale_color_brewer(palette="Dark2")
but I am getting a warning message:
2: In RColorBrewer::brewer.pal(n, pal) :
n too large, allowed maximum for palette Dark2 is 8
Returning the palette you asked for with that many colors
and I have checked the palettes available, the biggest one contains 12 colors but I need 14, so I am wondering if there is way to resolve this issue.
If you really want/need more colors than are given in a palette, you can concatenate two different palettes and then use scale_color_manual. I couldn't reproduce your example, but hopefully this communicates the general point:
mycolors = c(brewer.pal(name="Dark2", n = 8), brewer.pal(name="Paired", n = 6))
ggplot(derv, aes(x=Date, y=derv, colour = Season)) +
geom_point() +
geom_abline(intercept = 0, slope = 0) +
geom_abline(intercept = 2.578269274, slope = 0) +
geom_abline(intercept = -1.4242559021, slope = 0) +
scale_color_manual(values = mycolors)
As an aside, it would be great if you could provide a minimal and reproducible example next time. Perhaps just take a subset of your data and dput()
it into the question, or use one of the data sets you'll find by running data()
that most closely resembles the format of your data.
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