说我有这个数据帧df
:ggplot2,直方图:为什么y = ..density ..和stat =“density”有区别?
structure(list(max.diff = c(6.02, 7.56, 7.79, 7.43, 7.21, 7.65,
8.1, 7.35, 7.57, 9.09, 6.21, 8.2, 6.82, 7.18, 7.78, 8.27, 6.85,
6.72, 6.67, 6.99, 7.32, 6.59, 6.86, 6.02, 8.5, 7.25, 5.18, 8.85,
5.44, 6.44, 7.85, 6.25, 9.06, 8.19, 5.08, 6.26, 8.92, 6.83, 6.5,
7.55, 7.31, 5.83, 5.55, 4.29, 8.29, 8.72, 9.5)), class = "data.frame", row.names = c(NA,
-47L), .Names = "max.diff")
我想绘制这是用ggplot2
密度的情节:
p <- ggplot(df, aes(x = max.diff))
p <- p + geom_histogram(stat = "density")
print(p)
赋予,
现在,一个天真的问题:为什么不给出相同的结果?
p <- ggplot(df, aes(x = max.diff))
p <- p + geom_histogram(aes(y = ..density..))
print(p)
这是因为所选择的binwidth
或数bins
或其他一些参数的?到目前为止,我还没有能够调整这些参数来使它们相同。还是我策划了一些完全不同的东西?