【发布时间】:2017-12-09 17:58:22
【问题描述】:
我正在尝试创建一个包含 3 个调查季节的图表,每个调查季节都跨越一年的边界(即 2009-2010、2010-2011、2016-2017),但调查工作在每次调查的不同点开始和结束季节。我目前拥有的是:
我希望每个 x 轴显示该调查季的 11 月至 4 月(即 2009-2010 年调查季将显示 2009 年 11 月至 2010 年 4 月),以更好地显示调查工作在哪些方面缺乏年际比较。我只是不确定如何在scale_x_date() 的上下文中做到这一点。我目前的比例声明只是scale_x_date(date_breaks = '1 month',date_labels='%b')+ 到目前为止,我唯一的想法是基本上只创建一堆具有相关日期的 NA 数据并继续让日期自动缩放,但为了我未来的参考,我想知道是否有更好的创建这种“无年”日期限制的方法。
更多信息:
我的数据的头部(在这种情况下将在图的左上角):
structure(list(SPID = c("Cho_001", "Cho_001", "Cho_001", "Cho_001",
"Cho_001", "Cho_001"), season = c(2009, 2009, 2009, 2009, 2009,
2009), Date = structure(c(14579, 14580, 14581, 14582, 14583,
14584), class = "Date"), DayOfYear = c(335, 336, 337, 338, 339,
340), year = c(2009L, 2009L, 2009L, 2009L, 2009L, 2009L), month = c(12L,
12L, 12L, 12L, 12L, 12L), day = 1:6, RatePerMin = c(3.6667, 4.8667,
13.1667, 23.0333, 24.6667, 25.4667), N = c(3L, 30L, 30L, 30L,
30L, 30L), sd = c(3.5119, 6.9269, 8.1074, 4.2789, 4.9434, 4.2729
), se = c(2.0276, 1.2647, 1.4802, 0.7812, 0.9025, 0.7801), Illu = c(0.999348417128253,
0.999986511310919, 0.991435775301254, 0.955915838251852, 0.894428866388813,
0.810868946410883)), .Names = c("SPID", "season", "Date", "DayOfYear",
"year", "month", "day", "RatePerMin", "N", "sd", "se", "Illu"
), row.names = c(NA, -6L), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), vars = c("SPID", "season", "year", "month",
"day", "Date"), drop = TRUE, indices = list(0L, 1L, 2L, 3L, 4L,
5L), group_sizes = c(1L, 1L, 1L, 1L, 1L, 1L), biggest_group_size = 1L, labels = structure(list(
SPID = c("Cho_001", "Cho_001", "Cho_001", "Cho_001", "Cho_001",
"Cho_001"), season = c(2009, 2009, 2009, 2009, 2009, 2009
), year = c(2009L, 2009L, 2009L, 2009L, 2009L, 2009L), month = c(12L,
12L, 12L, 12L, 12L, 12L), day = 1:6, Date = structure(c(14579,
14580, 14581, 14582, 14583, 14584), class = "Date")), row.names = c(NA,
-6L), class = "data.frame", vars = c("SPID", "season", "year",
"month", "day", "Date"), drop = TRUE, .Names = c("SPID", "season",
"year", "month", "day", "Date")))
【问题讨论】:
-
您能否在问题中添加一个(小)数据集示例?
-
你在 facet_grid 中试过 scales = "free" 吗?
-
ed_sans:是的,我有。结果是链接的数字,并根据数据确定限制。
-
aosmith:数据已经在上面了。