Reputation: 377
I'm trying to understand the logic of the ggplot syntax and I don't understand why sometimes some parameters are in the geom part instead of the aes part.
For instance in geom_text
in which case size
have to be specified in geom
instead of aes
?
Upvotes: 0
Views: 117
Reputation: 5424
In ggplot aes()
is used to map a variable to the way it is displayed. Extending the documentation, if one wants to vary the geom_text()
by cyl
one would do
p <- ggplot(mtcars, aes(x=wt, y=mpg, label=rownames(mtcars)))
p + geom_text(aes(size = cyl))
Alternatively, one might wish to set an arbitrary value for all of the text displayed:
p + geom_text(size = 10)
Upvotes: 1