我是初学者ggplot2
。我无法使用date_minor_breaks
在 x 轴上显示季度“刻度”。
这是我的代码:
x<-c(seq(1:12))
time<-c("2010Q1","2010Q2","2010Q3","2010Q4","2011Q1","2011Q2", "2011Q3","2011Q4","2012Q1","2012Q2","2012Q3","2012Q4")
z<-data.frame(type = x,time = time)
z$time = as.yearqtr(z$time)
z$time = as.Date(z$time)
ggplot(data = z, aes(x=time,y=type)) +
geom_point() +
scale_x_date(date_labels = "%Y",date_minor_breaks = "3 months",name = "Year") +
theme_tufte() +
theme(legend.position = "none")
我在SO上研究了这个话题在ggplot2中使用scale_x_date格式化日期 https://stackoverflow.com/questions/10576095/formatting-dates-with-scale-x-date-in-ggplot2 and on https://github.com/hadley/ggplot2/issues/542 https://github.com/hadley/ggplot2/issues/542,并发现有一些关于此主题的问题报告。但是,我不太了解有关更改的对话ggplot2
因为距离我开始使用ggplot2才仅仅6天。
这是我得到的图表(它没有任何刻度线)...
下面是从 Excel 生成的带有“刻度线”的示例图表。请忽略值,因为我创建此 Excel 图表的目的是展示我正在寻找的内容,即“季度变动”。我很感激你的帮助。