I wish to position text in a ggplot
without specifying x
and y
positions, but instead using keywords, like e.g. in graphics::legend
("The location may also be specified by setting x to a single keyword from the list "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center").
Lets say I'm making a graph like this.
sp <- ggplot(mpg, aes(hwy, cty, label = "sometext")) +
geom_point()
I want to add the label to be printed in the same way in every graph. Calling the following simply prints text at every x
, y
value supplied to aes
.
sp + geom_text()
I could manipulate the x
and y
data supplied to geom_text()
to ensure that the text remained in the same relative position between graphs, but is there not a simply way to call position by default positions like "top"
, "bottom"
etc? I.e. sp + geom_text(position = "top")
.