Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge titles more aggressively #352

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

teunbrand
Copy link
Contributor

This PR aims to fix #349.

Briefly, when merging titles, multi-cell titles are not taken into account.
It allows cases such as the reprex from #349 to merge titles.

library(ggplot2)
devtools::load_all("~/packages/patchwork/")
#> ℹ Loading patchwork

p1 <- ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  labs(y = "mpg", x = "collected axis title")

p2 <- ggplot(mtcars) +
  geom_boxplot(aes(gear, disp, group = gear)) +
  labs(y = "gear", x = "collected axis title")

p1 + p2 + plot_layout(axis_titles = "collect_x", design = "AAB")

However, this also means that titles are merged over multi-cell titles. In the plot below, the mpg label is not repeated for the 2nd column, which used to be the case. The changed snapshot is related to this.

plots <- wrap_plots(rep(list(p1), 3))
layout <- plot_layout(design = "12\n32", axis_titles = "collect")
plots + layout

Created on 2024-02-12 with reprex v2.1.0

I couldn't find an elegant solution to keep both cases working, but I think the tradeoff might be worth it.

@thomasp85 thomasp85 merged commit 3a92584 into thomasp85:main Jul 8, 2024
14 checks passed
@thomasp85
Copy link
Owner

Thanks!

@teunbrand teunbrand deleted the merge_aggressively branch July 8, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

collecting axis titles does not work when using more complex designs
2 participants