-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
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 fromfreefunction (the currentfreefunction is much like thewrap_elements()function), it only free the selected axes.
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
ggtitle("Plot 1")
p3 <- ggplot(mtcars) +
geom_point(aes(hp, wt, colour = mpg)) +
ggtitle("Plot 3")
p5 <- ggplot(mpg, aes(class)) +
geom_bar() +
ylim(0, 65) +
coord_flip()plot_grid(free_align(p3, "l"), p5, ncol = 1L)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 settingaxisargument, 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
plot_grid(free_border(p3, "l"), p5, ncol = 1L)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 Gap between axis label and text if adjacent plot has vertical axis text #285, [Feature Request] Align panels without aligning axis titles #348 and axis panel size should be determind by its own axis label size #110 (comment).
plot_grid(free_lab(p3, "l"), p5, ncol = 1L)free_size: Removing the ggplot element sizes when aligning, we ususally want to combine this withfree_borderto 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
plot_grid(
patchwork::plot_spacer(),
free_size(free_border(p5, "l"), "l"),
p1, p3, nrow = 2L
)Metadata
Metadata
Assignees
Labels
No labels



