I have a series of multi-panel figures that I would like to have the same panel dimensions (i.e., plotting area). After searching for options on how to accomplish fixed panels, I settled on ggh4x because it retains the ggplot2 object type. However, when I add force_panelsizes() to my plot, the plots no longer align using plot_grid() from the cowplot library. As you'll see in the plot_grid() call, I would like these plots to align at the top of the graph and the x-axis, but I can't get it to work. I have include a reproducible example below:
library(ggplot2)
library(ggh4x)
library(cowplot)
a <- ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
theme(legend.position = "bottom") +
force_panelsizes(rows = unit(3, "in"),
cols = unit(3, "in"))
b <- ggplot(data = mpg) +
geom_boxplot(aes(x = as.factor(cyl), y = hwy)) +
force_panelsizes(rows = unit(3, "in"),
cols = unit(3, "in"))
plot_grid(
a,
b,
labels = c("A.", "B."),
vjust = 3,
#scale = 0.9,
ncol = 2,
align = 'h', axis = "bt"
)
ggsave(
"repro.png",
height = 6,
width = 7.5,
units = "in",
dpi = 300
)


following your code, I used ggh4x to enforce fixed panel sizes and then align the plots using cowplot, you can manually set the size of the plots before using align_plots.