-
Notifications
You must be signed in to change notification settings - Fork 167
Description
Hello,
and first of all, big, big thank you for a great package!
I have seen questions (very) similar to these around the web, but none of the proposed solutions seem to solve my issue. If this is not the appropriate place to ask, I apologize. I am trying to make the column widths across several plots in a patchwork uniform, but I am not competent enough to make them exactly equal. Below is the reprex:
# Creating some dummy data
df1 <- data.frame(x = rep(c(letters[1:5]), 2), y = c(1:10), type = rep(c("A", "B"), 5))
df2 <- data.frame(x = c(letters[1:6]), y = c(1:6))
df3 <- data.frame(x = c(letters[1:5]), y = c(4:8))
# Making plots
p1 <- ggplot(df1) +
geom_col(mapping = aes(x = x, y = y, fill = type),
position = position_dodge(width = 0.9)) +
theme(legend.position = "none")
p2 <- ggplot(df2) + geom_col(mapping = aes(x = x, y = y))
p3 <- ggplot(df3) + geom_col(mapping = aes(x = x, y = y))
# Patchwork no 1
p2 + p3 + plot_layout(widths = c(6, 5))
It may seem that the columns have equal width, but when exporting to PDF and loading the plot into Affinity Designer, the columns within one plot have equal widths; however, columns across the two plots have different widths. The difference is not much, but it is still present. For example, when setting width = 10 / 2.54, height = 5 / 2.54 for graphics region within the pdf() call, the column widths are 5.715 mm and 5.68 mm, respectively. In certain circumstances, these small differences can become important, and I wanted to ask what the proper way of calling the plot_layout() is in order to achieve perfectly equal column widths across different plots within a patchwork.
The same question applies to grouped column plots, similar to the one shown below:
Patchwork no 2
p1 + p2 + p3 + plot_layout(widths = c(10, 6, 5))
Thanks in advance, any help is greatly appreciated!