I have a ggplot object. I would like to add some text with annotate()
, and I would like to specify the coordinates of the text in npc units. Is this possible?>
As of 'ggpmisc' (>= 0.3.6) the following code works as expected (in CRAN as of 2020-09-10).
library(ggpmisc)
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
# default justification is "inward"
p + annotate("text_npc", npcx = 0.8, npcy = 0.75, label = "hello")
# same justification as default for "geom_text()"
p + annotate("text_npc", npcx = 0.8, npcy = 0.75, label = "hello",
hjust = "center", vjust = "middle")