Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cumulative histogram with percentage on the Y axis

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

like image 237
Gianni Spear Avatar asked Nov 12 '12 15:11

Gianni Spear


People also ask

What is a cumulative percentage histogram?

A cumulative histogram counts the cumulative cases over the range of cases; using the Salem data, it tells what percentage of the total number of cases accumulated each month and, therefore, how much of the outbreak had taken place.

How do you show percentages on a histogram?

A histogram which shows the proportion instead of the absolute amount can easily produced by weighting the data with 1/n , where n is the number of datapoints. Then a PercentFormatter can be used to show the proportion (e.g. 0.45 ) as percentage ( 45% ).

What does the cumulative percentage indicate?

a running total of the percentage values occurring across a set of responses. The total will either remain the same or increase, reaching the highest value of 100% after totaling all of the previous percentages.


1 Answers

Isn't this a plot of the empirical cumulative distribution function? As in

plot(ecdf(x))

which produces:

enter image description here

like image 88
Gavin Simpson Avatar answered Sep 20 '22 19:09

Gavin Simpson