I would like to put the annotation "a)" on the left had side of the y-axis of my plot. I have read that I should be using "custom_annotation", but the closest I have got is as follows:
#create dataframe for an example plot
df <- data.frame(matrix(c(1:3, 6:8, 11:13), nrow = 1))
names(df) <- paste0(rep(LETTERS[1:3], each = 3), 1:3)
sdf <- stack(df)
sdf <- transform(sdf, group = substring(ind, 1, 1),
obs = substring(ind, 2))
#example plot
require(ggplot2)
plt <- ggplot(sdf, aes(x = group, y = values)) +
geom_boxplot()+
annotation_custom(
grob = textGrob(label = "a)", hjust = 0, gp = gpar(cex = 1.5)),
ymin = 12.5,
ymax = 12.5,
xmin = 0.2,
xmax = 1)
plt
When I try to change the x min/x max to a negative number (i.e. -0.2) my annotation just disappears rather than shifting to the left of the y-axis. Any help would be greatly appreciated!