2017-03-29 44 views
0

是否可以在R中用条而不是线条步骤绘制 ecdf函数?R:ecdf带条而不是线

矿石有没有另一种方式来绘制累积直方图ggplot y轴上的累积密度而不是频率?

回答

1

ggplot具有开箱即用的功能,但不支持geom = "bar"。我们可以结合使用stat_bin()与特变..density..以柱状图版本的ecdf到达:

library(ggplot2) 
ggplot(df, aes(x)) + stat_ecdf(col = "red") + 
        stat_bin(aes(y = cumsum(..density..)/ 
             sum(..density..)), 
           alpha = 0.8) 

enter image description here

相关问题