My stacked plot is going all wonky in the later years. Could someone look at my code and tell me where I went wrong? I thought my code was identical to the example code (both below).
I am not very experienced with ggplot2 plot stacking so I might be making a simple error.
I wanted something that looked like:
The code to produce that produces the above stacked plot is available as part of The R Graphics Cookbook and can be found at Revolutions R Blog Post.
From The R Graphics Cookbook
library(ggplot2)
library(gcookbook)
ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
geom_area(colour="black", size=.2, alpha=.4) +
scale_fill_brewer(palette="Blues", breaks=rev(levels(uspopage$AgeGroup)))
I thought I had pretty much duplicated the syntax. But, it seems to me that I must have made a mistake somewhere.
lawsize <- as.data.frame(read.csv("https://raw.githubusercontent.com/EconometricsBySimulation/wild-monkey/master/usc.csv"))
ggplot(lawsize, aes(x=Year, y=KB, fill=factor(Name)))+
geom_area(colour="black", size=.2, alpha=.4)
scale_fill_brewer(palette="Blues", breaks=rev(levels(lawsize$Name)))
Thanks for your consideration in this matter! F