我在GGPLOT2使这个点阵图:如何使平滑密度适合ggplot2的dotplots?
ggplot(mtcars, aes(x = mpg)) + geom_dotplot()
我想表明某种平滑密度适合在散点图顶部的观察点。这看起来不正确:
ggplot(mtcars, aes(x = mpg)) + geom_dotplot() + geom_density()
我试图stat_smooth()
但我得到的错误:
> ggplot(mtcars, aes(x = mpg)) + geom_dotplot() + stat_smooth()
stat_bindot: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
Error: stat_smooth requires the following missing aesthetics: y
感谢。
什么看起来不正确?你意识到密度估计不会与分箱计数的规模相同,对吧? – joran 2013-04-25 21:38:45
@joran:正好。这就是为什么我需要一些适合内核密度的东西来适应实际的点堆,所以它们的尺寸大致相同 – user248237dfsf 2013-04-26 00:08:25
实际上,我认为它仅仅适合一个合适的内核密度估计值,这只是因为你不喜欢结果。看看我的意思,尝试使用'geom_density(adjust = 0.5)'。这里没有真正的“正确”,你只需要修改bin宽度和kde参数,直到你找到一些看起来令人愉悦的东西。 – joran 2013-04-26 01:31:43