Graphics Reference
In-Depth Information
Figure 10-5. Left: default order for legend; right: modified order
Discussion
Note that the order of the items on the x-axis did not change. To do that, you would have to set
the limits of scale_x_discrete() ( Changing the Order of Items on a Categorical Axis ) , or
change the data to have a different factor level order ( Changing the Order of Factor Levels ) .
In the preceding example, group was mapped to the fill aesthetic. By default this uses
scale_fill_discrete() (which is the same as scale_fill_hue() ), which maps the factor
levels to colors that are equally spaced around the color wheel. We could have used a different
scale_fill_ xxx () , though. For example, we could use a grey palette ( Figure 10-6 , left):
p + scale_fill_grey(start = .5 , end = 1 , limits = c( "trt1" , "trt2" , "ctrl" ))
Or we could use a palette from RColorBrewer ( Figure 10-6 , right):
p + scale_fill_brewer(palette = "Pastel2" , limits = c( "trt1" , "trt2" , "ctrl" ))
Search WWH ::




Custom Search