mapping (ordered) factors to colors in ggplot
问题 Consider this example data_frame(mylabel = c('month 18', 'month 19', 'month 20', 'month 21', 'month 22'), value = c(5,10,-2,2,0), time = c(1,2,3,4,5)) %>% ggplot(aes( x= time, y = value, color = mylabel)) + geom_point(size = 7) Here you can see that the variable mylabel has a natural ordering: month 18 comes before month 19 etc. However, this natural ordering is not preserved by the colors chosen by ggplot . In my real dataset, I have about 50 different months and I would like to use a color