library(ggforma)
library(ggplot2)
library(lattice)
library(patchwork)

# Install gridGraphics for Base R capture.
p1 <- ~plot(women)
p2 <- xyplot(weight ~ height, data = women)
p3 <- ggplot(women, aes(height, weight)) + geom_point()
p4 <- p3 + theme_forma()
figure <- ggplus(p1, p2, p3, p4, nrow = 2, align = "panel",
                 gap = c(x = 4, y = 6))

# Enter figure in the R console to preview it.

render_example <- function(file, device = ragg::agg_png) {
  ggsave(file, figure, width = 190, height = 150, units = "mm",
         device = device, dpi = 144, bg = "white")
}

png.file <- file.path(tempdir(), "composition-alignment.png")
render_example(png.file)
png.file
