Some journals require that figures with several graphs have each of the plots lettered. I'm trying to do the same with facet_wrap
in ggplot2
because I've organized the data in such a way that covariates for all my explanatory variables are in one column and the grouping variables for the covariates are in another column.
I followed the instructions here to give the effect that the x-axis label is different for each plot (when it's really a panel).
But I still need labels for each plot (column figure.letters
) in the figure, preferably in the top-left hand corner. I've attempted to add it in the facet_wrap
formula, so now each plot has two strip panels.
require(ggplot2)
my.df <- data.frame(
param = rep(c('Distance (km)', 'Energy (j)', 'Girth (m)', 'Height (cm)', 'Incline (degrees)'), each = 20),
explanatory = rnorm(100, 0, 1),
response = rnorm(100, 0, 1),
figure.letter = rep(LETTERS[1:5], each = 20)
)
ggplot(my.df, aes(x = explanatory, y = response)) +
geom_point() +
facet_wrap(. ~ param + figure.letter, strip.position = 'bottom') +
theme_bw() +
theme(
strip.placement = 'bottom',
strip.background = element_blank()
)
There are a lot of really good answers here, but they're more geared towards moving all the strip panels to the top and then left-justifying the panel text. I'm looking to separate the two strip panels so that the figure letter panel sits on top and is left-justified while the param
strip panel remains at the bottom.
I'm also hoping to avoid writing code for several plots and then use patchwork
to get the figure labels.
Is there a way to take the strip panel for the figure.letter
and move it to the top while keeping the strip panel for param
at the bottom?