0

I am wondering how it is possible to make a barplot where my data will be showed on opposite sides of the x-axis with two different y-axis?

I have two processes that go in different directions (one in + that need to go upwards and one in - that goes downward) all dates will each have one of each if that makes sense

It needs to look somewhat like this: Ravn, N. R. (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"))

At the moment I have two separate plots. I would like to have them in the same plot with GEP in the negative y-axis, pointing down, and the ER in the positive Y-axis pointing up.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 13 '21 at 18:11
  • 1
    Please do not vandalize your posts. By posting on the Stack Exchange network, you've granted a non-revocable right for SE to distribute that content (under the [CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/)). By SE policy, any vandalism will be reverted. – tripleee Sep 16 '21 at 09:02
  • Does this answer your question? [How to label a barplot bar with positive and negative bars with ggplot2](https://stackoverflow.com/questions/11938293/how-to-label-a-barplot-bar-with-positive-and-negative-bars-with-ggplot2) – M_1 Sep 16 '21 at 09:13

0 Answers0