Graphics Reference
In-Depth Information
library(plyr) # For the desc() function
ggplot(uspopage, aes(x = Year, y = Thousands, fill = AgeGroup, order = desc(AgeGroup))) +
geom_area(colour = "black" , size = .2 , alpha = .4 ) +
scale_fill_brewer(palette = "Blues" )
Figure 4-22. Reversed stacking order
Since each filled area is drawn with a polygon, the outline includes the left and right sides. This
might be distracting or misleading. To get rid of it ( Figure 4-23 ), first draw the stacked areas
withoutan outline (by leaving colour as the default NA value), and then add a geom_line() on
top:
ggplot(uspopage, aes(x = Year, y = Thousands, fill = AgeGroup, order = desc(AgeGroup))) +
geom_area(colour = NNA , alpha = .4 ) +
scale_fill_brewer(palette = "Blues" ) +
geom_line(position = "stack" , size = .2 )
Search WWH ::




Custom Search