different cdf plot produced by 2 different code
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I created 2 plots below using the same data but different code. Could anybody explain to me why the cdf plot (red line) in the top plot does not match the bottom plot.
The bottom plot is the correct plot (I think).
binneddata = histc(data,bin) ./ length(data);
[y2,x2] = ecdf(data);
plotyy(bin, binneddata, x2, y2, @(x,y)bar(x,y,1,'c'), 'stairs')
[y2,x2] = ecdf(data);
[y1,x1] = hist(data);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
回答(1 个)
Tom Lane
2013-1-24
When I try your commands after
rng(0)
data = 150 + 10*randn(200,1);
bin = 100:10:250;
I get the same cdf curve in the two figures. If you type
which stairs
do you see the one that is part of MATLAB or is there another one hanging around?
2 个评论
Tom Lane
2013-1-25
If I run my three lines of code, then your code with a "figure(2)" inserted before the second plotting command, I see both plots having (x=149.6995,y=0.5) on the blue curve. They look this way by eye and they show these values if I turn on the data cursor.
Notice that the two y axes on the same figure share the same x axis. You did substantial customization of the display. Could any of this have caused the x ticks for blue curve not to display, and to be different from the ones for the histogram? That's my only idea. Perhaps you can provide more code to reproduce both figures exactly and illustrate the problem.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!