Geom_text - Math expression label annotation - color, parsing, and subgraph labeling problems

If adding a single label, it is generally most straightforward to use annotate() since geom_text() will repeat the label based on the length of the plotting dataset.

From the documentation of geom_text():

geom_text and geom_label both add a label for each row in the data, even if coordinates x, y are set to single values in the call to geom_label or geom_text . To add labels at specified points use annotate() with annotate(geom = "text", ...) or annotate(geom = "label", ...)

So you could do

annotate(geom = "text", label = "Alpha[qq]%~~%10^10", x = 1.5, y = -3, 
               parse = TRUE, colour = "black", size = 7)

Alternatively you could pass geom_text() an empty data.frame and use inherit.aes = FALSE:

 geom_text(data = data.frame(), aes(label = "Alpha[qq]%~~%10^10", x = 1.5, y = -3), 
               parse = TRUE, colour = "black", size = 7, inherit.aes = FALSE)

In terms of adding your units, I wasn't sure I understood exactly. Do you want something like
label = "Alpha[qq]%~~%10^10~units"?

3 Likes