You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I absolutely love the axis_title = "collect" feature. While using it, I have noticed that there is an (unintended?) interaction when used with plot_spacer(). Specifically, when adding a spacer to the patchwork, the row with the spacer will have a title... This is how to reproduce the "issue" :
# Load necessary libraries
library(ggplot2)
library(patchwork)
set.seed(123)
n <- 100 # Number of random points
data <- data.frame(
x = rnorm(n), # Random normal distribution for x-axis
y = rnorm(n), # Random normal distribution for y-axis
category = sample(letters[1:3], n, replace = TRUE) # Random categories
)
# First plot: Random scatter plot
plot1 <- ggplot(data, aes(x = x, y = y, color = category)) +
geom_point(size = 3) + # Scatter plot points
theme_minimal() + # Minimal theme for aesthetics
labs(title = "Random Scatter Plot",
x = "Random X Values",
y = "Random Y Values",
color = "Category") + # Labels for plot
scale_color_manual(values = c("red", "blue", "green")) # Custom colors
# Second plot: Random density plot of the 'x' variable
plot2 <- ggplot(data, aes(x = x, fill = category)) +
geom_density(alpha = 0.5) + # Density plot with transparency
theme_minimal() + # Minimal theme for aesthetics
labs(title = "Density Plot of Random X Values",
x = "Random X Values",
y = "Density",
fill = "Category") + # Labels for plot
scale_fill_manual(values = c("red", "blue", "green")) # Custom colors
plot_list <- list(plot1, plot1, plot1,
plot1, plot1, plot1,
plot1, plot1, plot1,
plot1, plot1, plot1,
plot1, plot1, plot1,
plot1, plot1, plot_spacer(),
plot2, plot2, plot2)
(wrap_plots(plot_list, ncol = 3)&theme(legend.position = "none")) + plot_layout(axis_titles = "collect")
This results in the following plot:
Any insights how to mitigate this are much appreciated! I am using version patchwork_1.3.0.9000
The text was updated successfully, but these errors were encountered:
Hi all,
I absolutely love the
axis_title = "collect"
feature. While using it, I have noticed that there is an (unintended?) interaction when used withplot_spacer()
. Specifically, when adding a spacer to the patchwork, the row with the spacer will have a title... This is how to reproduce the "issue" :This results in the following plot:
Any insights how to mitigate this are much appreciated! I am using version
patchwork_1.3.0.9000
The text was updated successfully, but these errors were encountered: