r - 向构面添加阴影区域
问题描述
我对 R 真的很陌生,并试图自己学习它,但现在我被困在了一个地方。我试图在一个方面添加一个阴影区域,但它为每个方面添加了一个阴影区域。我只想强调从 2017-08-08 到 2017-08-16 的时间,但我不知道该怎么做。
我现在的代码如下所示:
ggplot(data = Andmed3, aes(x= Aeg, y = arch, group = Prooviala)) +
stat_summary(geom = "errorbar",fun.data = mean_se, aes(group = Prooviala, color = Prooviala)) +
stat_summary(fun = mean,geom="line",lwd=1,aes (group= Prooviala, color = Prooviala)) +
stat_summary(geom = "point", fun = mean, shape = 16, size = 2, aes(color = Prooviala)) +
facet_grid(~Periood, scales = "free_x", space = "free_x") +
labs(x = "Kuupäev", y = "Arhede 16S rRNA geenikoopiate arv")+
theme_bw() +
theme(axis.text.x = element_text(angle = 30, hjust = 1)) +
scale_x_datetime(date_breaks = "1 week", date_labels = " %e %b %y") +
geom_rect(aes(xmin = as.POSIXct('2017-08-08', format = '%Y-%m-%d'),xmax = as.POSIXct('2017-08-16', format = '%Y-%m-%d'),ymin = -Inf,ymax = Inf), alpha = 0.2, fill = 'grey')
我需要我的图表看起来像我的第二张照片,但只有在第一个方面突出显示背景。
有人可以帮我写代码吗?
谢谢你!
解决方案
推荐阅读
- reactjs - 如何在 React 测试库中设置 InitialState
- scala - 在 Spark 中更改日期格式会返回不正确的结果
- python-3.x - 如何将状态“DC”添加到 python 中“us”包中的状态列表中
- python - 带有 Zipfile 模块 Python 的大型 Zip 文件
- java - 替换Java字符串中的特殊字符
- android - 尝试访问 applicationContext 以保存 SharedPreferences 会返回 kotlinnullpointerexception
- r - 在 Rshiny 中的 tableOutput 中的下拉菜单中保存以前选择的值
- c# - 每个文件的过程数据记录
- r - 如何根据侧边栏存储过滤后的数据
- aws-lambda - 如何找到失败的 Lambda 调用的请求 ID?