GGPLOT2:使用geom_area()函数(ggplot2: using the geom_ar

2019-10-18 06:24发布

我有一个展示四个班每年,各自的总当年的股沿的数据帧。

> 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

当我运行ggplotfill指定的,我得到一个统一的灰色框,符合市场预期。

> ggplot(df, aes(x=year, y=share, group=class)) + geom_area() + scale_fill_brewer()

所以我尝试添加fill=class ,而这是行不通的。

> 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
> 

我可以做的是什么class的因素得到它与正常工作scale_fill_brewer() 这个想法,很显然,是遮阳根据其类图的每个区域。

谢谢。

Answer 1:

我只是有这个问题。 这是接缝

theme_set(theme_bw(base_size=9))

结果在错误的报道。 但

base_size <- 9
theme_set(theme_bw(base_size=base_size))

作品。

我用Google搜索,发现例如在learnr博客

我不知道什么的第一个例子不工作,虽然?



Answer 2:

这个问题在一些主题参数你可以设置,所以它走了,一旦我开始建立一个可运行的例子在这里重现。 谢谢您的帮助。



文章来源: ggplot2: using the geom_area() function
标签: r ggplot2