0

I made several weekley plots of different gaseous compounds (BVOCs) with ggplot and I put them together with plot_grid function. Obviously compounds have different scales and Y axis are not aligned. I wish align them by zero on Y axis.

I think that I can avoid to share the dataset and the single plots code, because the point is on plot_grid function that put them together.

Here the plot_grid function that I used: plot_grid(metmax,acetalmax,formicmax,acetmax,nrow = 4,align = "hv",rel_widths= c(1,1,1,1),rel_heights = c(1.2,1.2,1.2,1.2))

Here an example of how appear my final plot with Y axis out of phase.

jay.sf
  • 60,139
  • 8
  • 53
  • 110
Antonio Manco
  • 217
  • 2
  • 14

1 Answers1

0

If I understand it correctly, you want the line at y=0 to appear at the same height in all plots. That would require them all to have the same range and, by consequence, the same scale.

You can add to your ggplot() call the following:

+ ylim(min_value, max_value)

min_value and max_value can be calculated by the script by looking at the range of values occurring in your plot data.

https://ggplot2.tidyverse.org/reference/lims.html

user2332849
  • 1,421
  • 1
  • 9
  • 12
  • This is not a good solution, because in this way some plots will be easier to see properly than other. For example: if I set the max_value as the maximum value of the methanol (top-left plot, 3), plots with scale of two order of magnitude smaller will be compressed and difficult to see. I would look for something in the plot_grid function, but that i don't know. – Antonio Manco Mar 19 '20 at 16:45