I have a data frame showing four classes for each year, along with their respective shares of the total for that year.
> head(df)
class year share
1 class1 1975 0.806
2 class2 1975 0.131
3 class3 1975 0.018
4 class4 1975 0.045
5 class1 1976 0.788
6 class2 1976 0.151
When I run ggplot
with no fill
specified, I get a uniform gray box, as expected.
> ggplot(df, aes(x=year, y=share, group=class)) + geom_area() + scale_fill_brewer()
So I try to add fill=class
, and it doesn't work.
> ggplot(df, aes(x=year, y=share, group=class, fill=class)) + geom_area() + scale_fill_brewer()
Error in inherits(x, "factor") : object "base_size" not found
In addition: Warning message:
In inherits(x, "factor") : restarting interrupted promise evaluation
>
What can I do to the class
factor to get it working properly with scale_fill_brewer()
? The idea, obviously, is to shade each area of the graph according to its class.
Thanks.