I am creating a plot using ggplot::facet_wrap()
and I wonder how to automatically add numbers/letters to the label/title of each panel?
gridExtra
and complot
solutions are not what I am looking for. It is more related to this SO post: https://stackoverflow.com/a/52217208/10264278, especially the alternative using the stickylabeller
package. This package could be perfect but it seems not maintained anymore (I get package ‘stickylabeller’ is not available for this version of R
message when loading it, R version 4.0.5 (2021-03-31)).
Is it possible to acheive something similar to stickylabeller::label_glue()
with labeller()
function? Ideally I would like to avoid editting my data prior to the plotting process. Reason for that is I would like to be able to quickly change the labels e.g. switch from (a)
, (b)
to 1.
, 2.
.
What I get:
library(ggplot2)
ggplot(mtcars, aes(qsec, mpg)) +
geom_point() +
facet_wrap(. ~ am) +
theme_bw(base_size = 12)
Here is the expected output (without the am =
is fine):