Graphics Reference
In-Depth Information
cabbage_exp
Cultivar Date Weight sd n se
c39 d16
3.18 0.9566144 10 0.30250803
c39 d20
2.80 0.2788867 10 0.08819171
c39 d21
2.74 0.9834181 10 0.31098410
c52 d16
2.26 0.4452215 10 0.14079141
c52 d20
3.11 0.7908505 10 0.25008887
c52 d21
1.47 0.2110819 10 0.06674995
One problem with the default output is that the stacking order is the opposite of the order of
items in the legend. As shown in Figure 3-17 , you can reverse the order of items in the legend
by using guides() and specifying the aesthetic for which the legend should be reversed. In this
case, it's the fill aesthetic:
ggplot(cabbage_exp, aes(x = Date, y = Weight, fill = Cultivar)) +
geom_bar(stat = "identity" ) +
guides(fill = guide_legend(reverse = TRUE
TRUE ))
Search WWH ::




Custom Search