-
Notifications
You must be signed in to change notification settings - Fork 162
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
add option align_axis_title
#373
Conversation
Another example in #348 library(ggplot2)
library(tibble)
library(patchwork)
df <- mtcars |>
rownames_to_column("car") |>
as_tibble()
gg1 <- df |>
ggplot(aes(y = wt, x = car)) +
geom_col() +
theme_bw() +
xlab(NULL) +
ylab("Plot 1") +
theme(axis.text.x = element_blank())
gg2 <- df |>
ggplot(aes(y = "number_of_cylinders", x = car, fill = as.character(cyl))) +
geom_tile(width = 0.9) +
ylab("Plot 2") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
gg1 / gg2 + plot_layout(align_axis_title = FALSE) Created on 2024-08-03 with reprex v2.1.0 |
Example for comment #110 (comment) library(patchwork)
library(ggplot2)
p1 <- ggplot(diamonds, aes(clarity, price)) +
geom_boxplot() +
coord_flip()
lev <- levels(diamonds$cut)
long_label <- paste("Very Very Very Very", lev)
names(long_label) <- lev
p2 <- ggplot(diamonds, aes(cut, price)) +
geom_boxplot() +
scale_x_discrete(labels = long_label) +
coord_flip()
p1 + p2 + plot_layout(ncol = 1, align_axis_title = FALSE) Created on 2024-08-03 with reprex v2.1.0 |
Another example for facet panels: library(patchwork)
library(ggplot2)
p <- ggplot(mpg, aes(displ, cty)) +
geom_point()
p1 <- p + facet_grid(rows = vars(drv))
p2 <- p + facet_grid(vars(drv), vars(cyl))
p3 <- p + facet_wrap(vars(class))
p1 + (p2 + scale_y_continuous(labels = ~ paste0("very very long ", .x))) +
plot_layout(align_axis_title = FALSE, ncol = 1L) p3 + (p2 + scale_y_continuous(labels = ~ paste0("very very long ", .x))) +
plot_layout(align_axis_title = FALSE, ncol = 1L) Created on 2024-08-03 with reprex v2.1.0 |
Dear @thomasp85, I apologize for any inconvenience caused and kindly request your assistance in integrating this function into my package. The functionality of my package heavily depends on this particular function. I have developed a package that utilizes ggplot2 to generate complex heatmaps. The package functions smoothly, but it heavily relies on this specific function. Without integrating this function, there would be some areas with no data. If it is not possible to merge it in |
After learning
These function need lots of modifications of patchwork, I'll make another commits for this. Now I'll close this thread. |
Hi @Yunuuuu - thanks for your wish to improve upon patchwork. Before you spend too much time on new features it would be better to open an issue where your ideas can be discussed. In that way we can ensure that your time is best spend on work that will end up in the package |
Thanks @thomasp85 for your advice. I have made an issue to follow this |
fix #285, #348 and #110 (comment)
This PR provide the option to disable the alignment of the axis title.
Created on 2024-08-02 with reprex v2.1.0
~
~