在geom_histogram上叠加geom_density()(位置=“填充”)

时间:2018-07-27 17:01:59

标签: r ggplot2

我知道如何用ggplot2在密度直方图上覆盖密度图,但是当位置设置为填充时我无法弄清楚。我也有一个变量映射到直方图上的填充美学(因此填充位置)。帮助将不胜感激。下面是我的代码的精简版,以供参考(不含密度图):

assigned.data %>%
ggplot(aes(x = balance, fill = cluster)) +
  geom_histogram(aes(y = ..density..), binwidth = 50000, position = "fill")

编辑:已添加初始图

Density Histogram

0 个答案:

没有答案