r - 如何在 x 轴的每一侧制作条形图
问题描述
我想知道如何制作一个条形图,其中我的数据将显示在 x 轴的相对两侧,并带有两个不同的 y 轴?
我有两个进程朝着不同的方向前进(一个在 + 中需要向上,一个在 - 需要向下)如果有意义的话,所有日期都将各有一个
它需要看起来像这样: Ravn, NR (2017)
GEP.2015.plot <- ggplot(Salix_data.2015,aes(x = Flux_Date, y = GEP, fill = Treatment))
GEP.2015.bar <- (GEP.2015.plot+
stat_summary(fun=mean,geom="bar", position="dodge", width =0.8)+
stat_summary(fun.data = mean_se, geom = "errorbar",
width=0.2, position = position_dodge(0.8))+
theme(legend.position = "bottom")+
annotate(geom = "text", x = 1, y = -20000, label = "a")+
annotate(geom = "text", x = 2, y = -12000, label = "b")+
annotate(geom = "text", x = 3, y = -17000, label = "a")+
annotate(geom = "text", x = 4, y = -10000, label = "a")+
annotate(geom = "text", x = 3, y = -19000, label = "*")+
labs(title = "GEP by Date and Treatment in Salix arctica heath in 2015", x="Date",y="GEP"))
ER.2015.plot <- ggplot(Salix_data.2015,aes(x = Flux_Date, y = ER, fill = Treatment))
ER.2015.bar <- (ER.2015.plot+
stat_summary(fun=mean,geom="bar", position="dodge", width =0.8)+
stat_summary(fun.data = mean_se, geom = "errorbar",
width=0.2, position = position_dodge(0.8))+
theme(legend.position = "bottom")+
annotate(geom = "text", x = 1, y = 8000, label = "a")+
annotate(geom = "text", x = 2, y = 5000, label = "a")+
annotate(geom = "text", x = 3, y = 7500, label = "b")+
annotate(geom = "text", x = 3, y = 8000, label = "*")+
annotate(geom = "text", x = 4, y = 3000, label = "a")+
labs(title = "ER by Date and Treatment in Salix arctica heath in 2015", x="Date",y="ER"))
目前我有两个独立的地块。我想让它们在同一个图中,GEP 在负 y 轴上,指向下方,ER 在正 Y 轴上指向上方。
解决方案
推荐阅读
- javascript - 什么代码更快(“if null || undefined”与“调用断言”)?
- r - 使用某些 plyr 函数来计算不止一件事
- javascript - 无法使用 chart.js 2.7 生成多轴组合图(条形图/线形图)
- r - 按因子 B 的数值对因子 A 重新排序
- java - 从 java servlet 下载时文件损坏
- twitter-bootstrap - Bootstrap 和 Zeplin.IO
- python - 如何通过索引每个级别的 agg='sum' 的总数对多索引 pandas 数据帧数据透视表进行排序
- python - Wagtail:将 Orderable 类添加到 Orderable 类
- git - 如何忽略 git 存储库子目录中除单个文件之外的所有内容?
- r - ggplot2混淆矩阵geom_text标签