如果您考虑以下代码:
library(ggplot2)
df <- as.data.frame(matrix(rnorm(8),4,2))
colnames(df) <- c("x","y")
df$dates <- as.factor(c("april", "may", "june", "august"))
ggplot(df, aes(x=x, y=y, color=dates)) + geom_point(size=3, shape=20)
如何按照月份的时间顺序对图例进行排序?
答案 0 :(得分:2)
将df$dates<-
行替换为:
m <- c("april", "may", "june", "august")
df$dates <- factor(m, levels = m)