ovlay cdf plot on histogram

25 views (last 30 days)
John on 5 Oct 2012
Hi there,
I'm trying to overlay a cdf plot over a histogram like in this picture
I'm using this code but the cdf plot is not showing up over the histogram.
hold on
I would appreciate any help.

Accepted Answer

Tom Lane
Tom Lane on 5 Oct 2012
Edited: Tom Lane on 6 Oct 2012
It's there but it's on the histogram scale and it is obscured by the bars. Try this instead to put the cdf on a separate y axis:
x = randn(30,1);
[y2,x2] = ecdf(x);
[y1,x1] = hist(x);
  1 Comment
Giuseppe Degan Di Dieco
Giuseppe Degan Di Dieco on 17 Apr 2021
Dear Tom,
thank you for your explanation.
It helped me to produce the graph attached.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!