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

plot_layout(axes = "collect_y") does not collect y axes correctly #354

Closed
psychelzh opened this issue Mar 5, 2024 · 3 comments
Closed

Comments

@psychelzh
Copy link

psychelzh commented Mar 5, 2024

A simple example. The y axes for these two plots are indeed the same but collecting is not done. Tried corresponding "collect_x", which works as expect.

library(ggplot2)
library(patchwork)
d <- data.frame(x = rnorm(5), y = factor(LETTERS[1:5]))
p1 <- d |> ggplot(aes(x, y)) + geom_point()
p2 <- d |> ggplot(aes(x, y)) + geom_point()
p1 | p2 + plot_layout(axes = "collect_y")

p1 | p2 + plot_layout(axes = "collect")

Created on 2024-03-05 with reprex v2.1.0

@psychelzh psychelzh changed the title plot_layout(axes = "collect_y") does not collect y axis correctly plot_layout(axes = "collect_y") does not collect y axes correctly Mar 5, 2024
@thomasp85
Copy link
Owner

You are running into operator precedence issues, which are super annoying but not something patchwork can control as it works at the language level

(p1 | p2) + plot_layout(axes = "collect_y")

gives you the correct plot

@psychelzh
Copy link
Author

Ah, I am sorry for such disturbance. I did not realize this.

@psychelzh
Copy link
Author

Given this is not really related to patchwork, I am closing this. Thank you very much for explanation.

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

No branches or pull requests

2 participants