I have a data frame showing four classes for each year, as well as their respective shares for just 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 without specifying fill , I get a single gray square, as expected.
> ggplot(df, aes(x=year, y=share, group=class)) + geom_area() + scale_fill_brewer()
So, I am trying to add fill=class and it does not 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 with class coefficient so that it works fine with scale_fill_brewer() ? Obviously, the idea is to shade every area of โโthe graph according to its class.
Thanks.
source share