Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ecdf是否可以在 R 中用条形图而不是线或步骤来绘制 函数?
ecdf
或者有没有另一种方法来绘制累积直方图,ggplot在 y 轴上使用累积密度而不是频率?
ggplot
ggplot具有stat_ecdf()开箱即用的功能,但不支持geom = "bar". 我们可以stat_bin()结合使用特殊变量..density..来得到一个条形图版本ecdf:
stat_ecdf()
geom = "bar"
stat_bin()
..density..
library(ggplot2) ggplot(df, aes(x)) + stat_ecdf(col = "red") + stat_bin(aes(y = cumsum(..density..)/ sum(..density..)), alpha = 0.8)