I'd like to plot two graphs ontop of each other like in this post.
Experimental data: I have continuous variable displaying the angle of wind on a given day in a list called expt$iso_xs[,8]
, I then have the wind speed corresponding to that angle in expt$iso_xs[,2]
.
df<-data.frame(expt$iso.xs)
head(expt$iso.xs)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
736105.4 16.62729 2.183740 7.234774 0.9791632 4.01 4.20 238.62
736105.4 18.96705 2.489668 7.036234 0.9640366 3.82 4.00 243.14
736105.5 20.52089 2.687636 10.355394 1.3698454 4.99 5.14 247.02
736105.5 19.94449 2.611556 10.306912 1.3655301 4.85 5.12 249.57
736105.5 19.43309 2.551787 11.098302 1.4646251 4.83 5.12 243.89
736105.5 20.48259 2.689075 11.928011 1.5710530 4.89 5.09 254.23
Simulation data: I have a data.frame z
that contains predictions for a subset of the above angles (0-90º).
head(z,15)
Tracer angle treatment bigangle
71.101 0 S 150
71.101 0 S 150
71.105 15 S 165
71.105 15 S 165
71.098 30 S 180
71.098 45 S 195
71.114 60 S 210
71.114 80 S 230
71.110 90 S 240
Plotting it using bigangle as factor and Tracer as :
ggplot() +
geom_boxplot(data=z, aes(y = (3600/Tracer/93.241), x = factor(bigangle)),outlier.shape = NA,outlier.colour = NA)+
coord_cartesian(ylim=c(0, 1))+
labs(x = "Angle", y = "Normalised ACh" )+
scale_x_discrete(labels=seq(0,360,10))+
theme_classic()
looks like this:
I'd like to superimpose the boxplot ontop of the portion of red points (between 150º and 240º) but the following doesn't work:
ggplot() +
geom_boxplot(data=z, aes(y = (3600/Tracer/93.241), x = factor(bigangle)),outlier.shape = NA,outlier.colour = NA)+
geom_point(data=df, aes(y = X2/45, x = X8),color="red")+
coord_cartesian(ylim=c(0, 1))+
labs(x = "Angle", y = "Normalised ACh" )+
scale_x_discrete(labels=seq(0,360,10))+
theme_classic()
Any thoughts would be much appreciated, Cheers