Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Set the labels in the scale
(Figure 10-13, left):
library(gcookbook)# For the data set# The base plotp<-ggplot(PlantGrowth,aes(x=group,y=weight,fill=group))+geom_boxplot()# Change the legend labelsp+scale_fill_discrete(labels=c("Control","Treatment 1","Treatment 2"))
Note that the labels on the x-axis did not change. To do that,
you would have to set the labels of
scale_x_discrete() (Changing the Text of Axis Labels), or change the data to have
different factor level names (Changing the Names of Factor Levels).