Here is my data:
a = c("May-15","Jun-15","Jul-15", "Aug-15","May-16","Jun-16","Jul-16","Aug-16")
b = c(2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016)
c = c(0.19, 0.22, 0.25, 0.17, 0.22, 0.23, 0.17, 0.14)
df = data.frame(a, b, c)
I want to make a scatterplot with this data and differentiate color by year (b), not month-year (a).
ggplot()+
geom_point(data=df, aes(x=a, y=c))
I am not sure what to add to this that doesn't immediately assign colors to the month-year (b) factor, since that is what I am graphing. It seems like this would be fairly simple, but I am having a hard time changing the colors at all. Thank you!
library(ggplot2)
a = c("May-15","Jun-15","Jul-15", "Aug-15","May-16","Jun-16","Jul-16","Aug-16")
b = c(2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016)
c = c(0.19, 0.22, 0.25, 0.17, 0.22, 0.23, 0.17, 0.14)
df = data.frame(a, b, c)
ggplot(data=df, aes(x=a, y=c))+
geom_point(aes(color = b, size = 10))+
scale_fill_continuous(guide = "colourbar")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.