【发布时间】:2019-04-12 20:47:19
【问题描述】:
我想用月份作图,但 x 轴不按顺序排列,例如“Apr”、“Aug”、“Nov”..... 但我希望 x 轴上的顺序类似于“Jan”、“Feb”、“Mar”........
#change the format of date
date_month <- format(date_1, "%b")
class(date_month)
[1] "character"
head(date_month)
[1] "Jul" "Jul" "Jul" "Jul" "Jul" "Jul"
plot(table(date_month), xlab = "Month", ylab = "count")
我试过了:
x1 <- factor(date_month, levels=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"))
plot(y ~ x1)
和:
plot(table(date_month), xlab = "Month", ylab = "count")
axis(date_month,labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"))
根本不起作用。有人可以帮我解决这个问题吗?非常感谢。
【问题讨论】:
标签: r plot data-science data-analysis