I have a series of ggplot2
graphics with a constant number of horizontal but differing number of vertical facets. I would like to save the graphics as .pdf on landscape a4 format.
However, I don't know how I can achieve identical proportions of the facets. If I try to tweak it manually and vary width
and height
for different numbers of vertical facets, the scales vary between plots, i.e., I get different points sizes and line widths.
In essence, how can I achieve identical facets sizes and scales for plots with a variable number of (vertical) facets?
Here is an example:
df <- expand.grid(a = 1:2, b = 1:5, x = 1:10)
df$y <- df$x
plot <- ggplot(data = df, mapping = aes(x = x, y = y)) +
geom_point()
plot1 <- plot + facet_grid(facets = "a ~ b")
plot2 <- plot + facet_grid(facets = ". ~ b")
ggsave(filename = "./figures/plot1.pdf", plot = plot1,
height = 210, width = 297, units = "mm")
ggsave(filename = "./figures/plot2.pdf", plot = plot2,
height = 210, width = 297, units = "mm")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…