說我有這個數據幀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
或其他一些參數的?到目前爲止,我還沒有能夠調整這些參數來使它們相同。還是我策劃了一些完全不同的東西?