我正在使用 geom_path 绘制平均值的时间序列,并使用 geom_ribbon 添加具有最小值最大值的功能区。时间序列中存在一些数据差距,但该图保持连接线。在附图中,最后一个面板显示了数据中的差距。该数据没有 x 或 y 条目。有什么办法可以控制这个吗?
这是我的顶部面板的绘图代码:
ggplot(stat_total, aes(color=gas)) +
geom_path(aes(x=date_mean, y=conc_mean, color=gas), size=1.2, na.rm = T) +
geom_ribbon(aes(x=date_mean, ymin=conc_min, ymax=conc_max, fill=gas), color="grey70", alpha=0.4, na.rm = T)+
scale_x_datetime(date_breaks = "3 weeks" , date_labels = "%d-%b") +
xlab(NULL) +
ylab('[ppb]') +
theme_bw() +
facet_wrap(gas~.,scales = 'free_x',ncol = 1,nrow=2)
Run Code Online (Sandbox Code Playgroud)
以及数据样本:
structure(list(day = c(6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L,
11L, 11L, 12L, 12L, 13L, 13L, 15L, 15L, 16L, 16L, 17L, 17L, 18L,
18L, 20L, 20L, 21L, …Run Code Online (Sandbox Code Playgroud)