Hi ggplot2 experts
How do I identify the optimal height and width to save this patchwork plot?
My objective is to work out how to specify a fixed panel size for a plot using patchwork::plot_layout as below - and then save it with the optimal dimensions (i.e. not excess whitespace in the example below)
library(tidyverse)
library(palmerpenguins)
library(patchwork)
p <- penguins |>
drop_na(sex) |>
ggplot() +
geom_point(
aes(x = bill_depth_mm,
y = body_mass_g,
colour = species),
) +
patchwork::plot_layout(
widths = unit(50, "mm"),
heights = unit(50, "mm"),
) +
theme(plot.background = element_rect(fill = "black"))
p
ggsave(
filename = "temp.png",
# width = 110, #guessing
# height = 70, #guessing
units = "mm",
)