我正在嘗試在 R.ggplot 中繪制多個相對頻率的直方圖
uj5u.com熱心網友回復:
以下是內置iris資料集的一些基本示例。相對部分是通過將密度乘以 binwidth 獲得的。
library(ggplot2)
ggplot(iris, aes(Sepal.Length, fill = Species))
geom_histogram(aes(y = after_stat(density * width)),
position = "identity", alpha = 0.5)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(iris, aes(Sepal.Length))
geom_histogram(aes(y = after_stat(density * width)))
facet_wrap(~ Species)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2022-03-07 by the reprex package (v2.0.1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/440271.html
