I have a 6x6 grid (sites along the side and year along the top), showing abundance (y) over time(x).
I have used facet_grid to build the plot, using free_y. This has plotted a figure with each row having a shared y axis. I need to have a free_y for all the panels individually and I know that facet_grid doesnt allow this, while facet_wrap does. I would like to use facet_grid becuase it keeps the order of the panels, with columns for each year, and rows for each site.
I've tried using the lemon package with the facet_rep_grid function but this hasn't worked. Does anyone know how I can free_y across all the panels seperately?
Thanks
CodePudding user response:
One suggestion is to use ggh4x::facet_grid2() to set independent y scales. (Disclaimer: I'm the author of ggh4x). Example with standard dataset below:
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = as.factor(cyl)))
geom_point()
ggh4x::facet_grid2(vars(year), vars(drv),
scales = "free_y", independent = "y")


