I am trying to annotate many plots iteratively. I want an annotation to appear in the exact same place on all graphs, but they all have different y-axis scales. How do I annotate a graph without using the y-values? There must be a data-independent way, but I think I am missing a key piece of vocabulary so my searching has been fruitless.
Normally, I would add, e.g., annotate("text", x = 5, y = 10)
to the ggplot object, but this doesn't work because the range of y varies widely between groups.
Bearing in mind there are around 30 plots to keep track of, here is a toy example using mtcars and ggpubr.
library(ggpubr)
ggboxplot(mtcars, x = "gear", y = "wt") +
annotate("text", x = 2, y = 5, label = "I should be in the same place in both plots")
ggboxplot(mtcars, x = "gear", y = "disp") +
annotate("text", x = 2, y = 5, label = "I should be in the same place in both plots")