Graphics Reference
In-Depth Information
Figure 10-8. With the legend title set to “Condition”
Discussion
It's also possible to set the title of the legend in the scale specification. Since legends and axes
are both guides, this works the same way as setting the title of the x- or y-axis.
This would have the same effect as the previous code:
p + scale_fill_discrete(name = "Condition" )
If there are multiple variables mapped to aesthetics with a legend (those other than x and y ), you
can set the title of each individually. In the example here we'll use \n to add a line break in one
of the titles ( Figure 10-9 ):
library(gcookbook) # For the data set
# Make the base plot
Search WWH ::




Custom Search