Graphics Reference
In-Depth Information
Figure 3-18. Stacked bar graph with reversed stacking order
It's also possible to modify the column of the data frame so that the factor levels are in a different
order (see Changing the Order of Factor Levels ) . Do this with care, since the modified data could
change the results of other analyses.
For a more polished graph, we'll keep the reversed legend order, use scale_fill_brewer() to
get a different color palette, and use colour="black" to get a black outline ( Figure 3-19 ):
ggplot(cabbage_exp, aes(x = Date, y = Weight, fill = Cultivar)) +
geom_bar(stat = "identity" , colour = "black" ) +
guides(fill = guide_legend(reverse = TRUE
TRUE )) +
scale_fill_brewer(palette = "Pastel1" )
Search WWH ::




Custom Search