patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

axis alignment

Open r2evans opened this issue 10 months ago • 0 comments

It's possible this related to (or a dupe of) https://github.com/thomasp85/patchwork/issues/166 ...

Example code:

dats <- split(mtcars, ~ cyl)
ggs <- lapply(dats, function(dat) free(ggplot(dat, aes(mpg, disp)) + geom_point() + geom_vline(xintercept = 18)))
des <- do.call(c, Map(function(x, i) area(l=min(c(18, x$mpg)), r=max(c(18, x$mpg)), t=i, b=i), dats, seq_along(dats)))
des
# 3 patch areas, spanning 33 columns and 3 rows
#     t  l b  r
# 1:  1 18 1 33
# 2:  2 17 2 21
# 3:  3 10 3 19
Reduce(`/`, ggs) + plot_layout(design = des)

Image

Is it possible to align the plots so that the vlines (all at 18) are aligned? In this example, I'd like to not extend all scales to the max range of values. (I've tried free(type=) variants, no significant improvement.)

r2evans avatar Mar 05 '25 21:03 r2evans