Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

ovlay cdf plot on histogram

Asked by John on 5 Oct 2012

Hi there,

I'm trying to overlay a cdf plot over a histogram like in this picture

https://dl.dropbox.com/u/54057365/All/hist.JPG

I'm using this code but the cdf plot is not showing up over the histogram.

hist(x)
hold on
cdfplot(x)

I would appreciate any help.

Thanks

0 Comments

John

Products

No products are associated with this question.

1 Answer

Answer by Tom Lane on 5 Oct 2012
Edited by Tom Lane on 6 Oct 2012
Accepted answer

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);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')

0 Comments

Tom Lane

Contact us