geom_text(mapping = NULL, data = NULL, stat = "identity", position = "identity", parse = FALSE, ...)
aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.
layer. This can include aesthetics whose values you want to set, not map. See
layerfor more details.
geom_text understands the following aesthetics (required aesthetics are in bold):
# Change size of the label p + geom_text(size=10)
# You can display expressions by setting parse = TRUE. The # details of the display are described in ?plotmath, but note that # geom_text uses strings, not expressions. p + geom_text(aes(label = paste(wt, "^(", cyl, ")", sep = "")), parse = TRUE)
# Add an annotation not from a variable source c <- ggplot(mtcars, aes(wt, mpg)) + geom_point() c + geom_text(data = NULL, x = 5, y = 30, label = "plot mpg vs. wt")
# Or, you can use annotate c + annotate("text", label = "plot mpg vs. wt", x = 2, y = 15, size = 8, colour = "red")
# Use qplot instead qplot(wt, mpg, data = mtcars, label = rownames(mtcars), geom=c("point", "text"))
# You can specify family, fontface and lineheight p <- ggplot(mtcars, aes(x=wt, y=mpg, label=rownames(mtcars))) p + geom_text(fontface=3)