ovlay cdf plot on histogram
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
John
le 5 Oct 2012
Commenté : Giuseppe Degan Di Dieco
le 17 Avr 2021
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.
hist(x)
hold on
cdfplot(x)
I would appreciate any help.
Thanks
0 commentaires
Réponse acceptée
Tom Lane
le 5 Oct 2012
Modifié(e) : Tom Lane
le 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);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
1 commentaire
Giuseppe Degan Di Dieco
le 17 Avr 2021
Dear Tom,
thank you for your explanation.
It helped me to produce the graph attached.
Best.
Best.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/586716/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/586716/image.jpeg)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!