egg and patchwork, two packages useful for laying out and labelling figures for publication, don't actually make very similar-looking tags all the time. I happen to really like the ones made by egg:tag_facet, and would like to make sure my other plots have the same tags. How can I do this at a high level?
In the example below, I have fudged it so that my imaginary "figure 1" has two plots arranged with (and tagged by) patchwork and "figure 2" has a single, multi-panel plot that uses ggplot2::facet_grid and is tagged with egg. But the legwork here seems a bit extreme, and the plot.tag.position is bespoke at best, and also probably looks pretty terrible. What's the clean way to do this?
library(patchwork)
library(egg)
library(tidyverse)
svp <- iris %>%
ggplot(aes(Sepal.Length, Petal.Length)) +
geom_point() +
theme_classic() +
labs(x = "sepal length (mm)"
, y = "petal length (mm)")
pps <- iris %>%
ggplot(aes(Species, Petal.Length)) +
geom_boxplot() +
theme_classic() +
labs(x = "species"
, y = NULL)
# imagine this was fig 1
svp +
theme(plot.tag.position = c(0.22, 0.97) # klugey numbers
, text = element_text(face = "bold", size = 0.8*11)
, axis.title = element_text(face = "plain", size = 11)
, axis.text = element_text(face = "plain", size = 0.8*11)
) +
pps +
theme(plot.tag.position = c(0.15, 0.97) # klugey numbers
, text = element_text(face = "bold", size = 0.8*11)
, axis.title = element_text(face = "plain", size = 11)
, legend.title = element_text(face = "plain", size = 11)
, legend.text = element_text(face = "plain", size = 11)
, axis.text = element_text(face = "plain", size = 0.8*11)
) +
plot_annotation(tag_levels = 'a')
# and this was fig 2
slvswps <- iris %>%
ggplot(aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_grid(~Species) +
theme_classic() +
theme(panel.spacing.x = unit(1.2, "lines")
, strip.text.x = element_text(size = rel(0.8))
) +
labs(x = "sepal length (mm)", y = "sepal width (mm)")
tag_facet(slvswps, open = NULL, close = NULL)