Closed Yunuuuu closed 2 months ago
plot_grid(
p3 + theme(legend.position = "top"),
p3 + theme(legend.position = "left"),
p3 + theme(legend.position = "bottom"),
p3 + theme(legend.position = "right"),
nrow = 2L,
guides = TRUE
)
If it's okay to merge these features (or some), I would happy to make a commit in the patchwork project.
Thanks - I'm not sure I understand the distinction between free_lab()
and free_border()
- can you provide an example that shows where it differs?
Sorry for the missing example. The functions free_lab()
and free_border()
have a distinction in terms of placement on either the top or bottom side of the panel. Specifically, the top side contains the title
and subtitle
, while the bottom side contains the caption
. free_lab()
does not attach these elements in the panel area. Please note the title of the right plot.
p1_top <- ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
ggtitle("Plot 1") +
ggplot2::scale_x_continuous(position = "top")
plot_grid(p1_top, free_lab(p3))
plot_grid(p1_top, free_border(p3))
Ah, I see... thanks for the examples.
I see at least a place for the functionality of free_align()
, free_lab()
and free_size()
in patchwork. However, I think there is a minimally intrusive way of doing this on top of the free()
functionality already provided which I'll try to pursue, so hold off a bit before you spend time porting your approach to patchwork
Thanks
I have created some features for patchwork, which will modifying the core codes of patchwork. I hope these features can be merged into patchwork. These functions are now deposited in https://github.com/Yunuuuu/ggalign (See scripts begin with
alignpatch-
)free_align
: if we want to compose plots without alignment of some panel axes (panel won't be aligned). we can wrap the plot withfree_align
. Note: this is different fromfree
function (the currentfree
function is much like thewrap_elements()
function), it only free the selected axes.free_border
: If we want to compose plots without alignment of the panel borders (but still align the panels themselves), we can wrap the plot withfree_border
. This does the same work with cowplot::plot_grid by settingaxis
argument, we only align the panel, but border like axis titles won't be aligned. Note title, subtitle, and caption won't be aligned too. If you want to free axes and axes title, try to usefree_lab
free_lab
: Similar withfree_border
, but it will only operate the axis and axis title (labs). If we want to compose plots without alignment of the axis title, we can wrap the plot withfree_lab
. This should fix https://github.com/thomasp85/patchwork/issues/285, https://github.com/thomasp85/patchwork/issues/348 and https://github.com/thomasp85/patchwork/issues/110#issuecomment-615000426.free_size
: Removing the ggplot element sizes when aligning, we ususally want to combine this withfree_border
to suspend the empty sized ggplot elements. Note the the second plot (on right-top), the left side of the panel won't count space when aligned. This help make more compact layout