请考虑以下数据并绘制。每三个月定义一次date_breaks
,第一个休息时间是feb
。但我想从jan
开始。它每两个月工作一次,请参阅第二个图。我试图指定限制(请参见代码)无济于事。
library(ggplot2)
df_foo <- data.frame(date = as.Date(c('2008-06-01','2008-07-01','2008-07-01','2009-04-01','2009-04-01','2010-04-01')))
ggplot(df_foo, aes(x = date)) +
stat_count(geom = 'line', aes(y = ..count..)) +
scale_x_date(date_breaks = '3 months', date_labels = '%b',
limits = c(as.Date('2008-01-01'), as.Date('2010-12-01')))
ggplot(df_foo, aes(x = date)) +
stat_count(geom = 'line', aes(y = ..count..)) +
scale_x_date(date_breaks = '2 months', date_labels = '%b',
limits = c(as.Date('2008-01-01'), as.Date('2010-12-01')))
由reprex package(v0.2.1)于2018-11-29创建