Closed junjunlab closed 1 year ago
You can use scale_y_facet()
to set the range for a group of panels. The first argument is an expression that instructs to which panels to apply the scales. It can also be COL == 1
and COL == 2
to work with the panel layout instead of the facetting variables.
library(ggh4x)
#> Loading required package: ggplot2
ggplot(mtcars, aes(mpg, disp)) +
geom_point() +
facet_grid2(cyl ~ vs, scales = "free_y", independent = "y") +
scale_y_facet(
vs == 0,
limits = range(mtcars$disp[mtcars$vs == 0])
) +
scale_y_facet(
vs == 1,
limits = range(mtcars$disp[mtcars$vs == 1])
)
Created on 2023-03-28 with reprex v2.0.2
Thank you very much, I will have try!
Hi, thanks for giving this great tool. How can I set the each column have same y limit when using facet_grid2 with scales = "free",independent = "y", the follwing is my plot:![1679982776277](https://user-images.githubusercontent.com/64965509/228141178-6e8676df-1310-449b-96ba-3c5a5fb68de8.png)
I want the each facet column have same y ranges. Thanks!