There is probably a very easy solution to my problem but I couldn't find a satisfying answer online.
Using the following command I was able to create the following boxplot graph and overlay it with the individual data points:
ggplot(data = MYdata, aes(x = Age, y = Richness)) +
geom_boxplot(aes(group=Age)) +
geom_point(aes(color = Age))
There are several things I would like to add/change:
1. Change the line color and/or fill of each boxplot (depending on "Age") using 6 different colors from left to right:
c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00")
I tried
ggplot(data = MYdata, aes(Age, Richness)) +
geom_boxplot(aes(group=Age)) +
scale_colour_manual(values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00"))
but it results in a "Continuous value supplied to discrete scale"
error.
2. Change the color of each data point (depending on "Age") using 6 different colors from left to right:
c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00")
I tried:
ggplot(data = MYdata, aes(Age, Richness)) +
geom_boxplot(aes(group=Age)) +
geom_point(aes(color = Age)) +
scale_colour_manual(values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00"))
but it also results in an error:
Continuous value supplied to discrete scale
3. Change the text in the legend to "0 month", "1 month", "3 months", "6 months", "9 months", "12 months"