aes
creates a list of unevaulated expressions that describe how variables in the data are mapped to visual properties of geoms.
xlab
and ylab
are not counted as visual properties of geoms
, they are labels for the scales
that define the x
and y
axes.
You can define these in numerous ways
# given a base plot
baseplot <- ggplot(seednumber, aes(x = Study.Site, y = Seed.Number, colour = Country)) +
geom_boxplot()
1) The simplest is to use the functions labs
or xlab
and ylab
baseplot + labs(x = "Study Site", y = "Number of seeds in a podr")
# or
baseplot + xlab("Study Site") + ylab("Number of seeds in a podr")
note you can use labs
to change the label of any scale (including those mapped in aes
)
2). You have more control over the scales
using the relevant scale_..._...
functions
eg
baseplot + scale_x_discrete(name = "Study Site") +
scale_y_continuous(name = 'Number of seeds in a podr')