累积直方图,Y轴显示百分比

6
我希望您能在R项目中绘制一个累积直方图,其中Y轴报告的是百分比而不是频率。请注意保留HTML标记。
x <- c(rnorm(100), rnorm(50, mean=2,sd=.5))
h <- hist(x, plot=FALSE, breaks=20)
h$counts     <- cumsum(h$counts)
h$density    <- cumsum(h$density)
plot(h, freq=TRUE, main="(Cumulative) histogram of x", col="white", border="black")
box()

感谢您的帮助。

hist(data, freq=FALSE) 中设置 freq=FALSE,以获取概率“百分比”,而不是频率。 - Jilber Urbina
能否添加/更改带有线条的栏? - Gianni Spear
4个回答

22

这不是经验累积分布函数的图吗?就像

plot(ecdf(x))

生成:

输入图像描述


4

对于柱形图直方图,您需要执行以下操作:

x <- c(rnorm(100), rnorm(50, mean=2,sd=.5))
hist( x,plot=FALSE) -> h # do a histogram of y and assign its info to h
h$counts <- cumsum(h$counts)/sum(h$counts) # replace the cell freq.s by cumulative freq.s
plot( h ) # plot a cumulative histogram of y

来源: http://influentialpoints.com/Training/basic_statistics_cumulative_plot.htm

累积图是一种用于可视化数据分布的图表。它显示了在给定阈值以下或以上的数据点数量所占的百分比。在IT技术中,累积图通常用于分析性能数据、网络延迟和其他度量值。通过观察累积图,可以快速识别出在某个时间点或特定条件下数据的分布情况。

2

也可以尝试:

plot( sort(x), (1:length(x))/length(x), type="l" )


1
一个整洁的方法是尝试:

Try:

plot.ecdf(x)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接