Cumulative histogram with percentage on the Y axis
19,064
Solution 1
Isn't this a plot of the empirical cumulative distribution function? As in
plot(ecdf(x))
which produces:
Solution 2
For a column plot histogram, you will want to do:
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
Source: http://influentialpoints.com/Training/basic_statistics_cumulative_plot.htm
Solution 3
Also try:
plot( sort(x), (1:length(x))/length(x), type="l" )
Solution 4
For a neat method Try:
plot.ecdf(x)
Author by
Gianni Spear
Updated on June 19, 2022Comments
-
Gianni Spear almost 2 years
I wish to plot in R project a cumulative histogram where on the Y axes is reported the percentage instead of the frequency
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()
Thanks for help