I am trying to make a combined plot with the same y-limits. In here there are two facetwrapped boxplots. I would normally set the y-limits manually at the same level, but this messed up the medians and thus the direction of the line in the left plot (see image). Therefore the scales in this plot are set scale = "free_y"
My question: Is there a way to copy the y-axis from a plot, and use this exact scale on another plot? / What are the alternatives to find the exact y-limits a boxplot uses?
For now I have tried obtain the y-limits of the left facetwrapped plot (see image), and use this information to manually set the same y-limit on the right facetwrapped plot(see image) (This plot I am able to set y-limits manually without messing up the plot).
To obtain the exact Y-limits I have tried:
- par("usr") but this gave me 0 1 0 1 values
- Find the min and max value of the data from the leftplot (see image) through the code below
Range <- range(c(totalVH$MeanAbundance))
Range
This helped, but did not make the axis exactly the same. I've been searching for alternative solutions, but cant seem to find one that works for me..
Here the code I use for my plot. It combines 2 individual facetwrapped boxplots (AbundancePlotVH & boxplotVHAbundance)
prow<- plot_grid(AbundancePlotVH + theme(legend.position="none"), boxplotVHAbundance + theme(legend.position="none", axis.text.y = element_blank(), axis.ticks.y = element_blank(),
VH<- plot_grid(title, prow, legend, ncol = 1, rel_heights = c(1, 10), axis = "l", align = "v")
VH