
How to plot two histograms: one line over another bar?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have been searching for a way to graph two histograms on the same figure. Most of them are two bar graphs either side-by-side or on top of each other; however, I want one set of data to be a traditional bar graph and the other to be a line drawing overlaid on top of the bar graph. Both data are roughly normal distributions, but are of different size.
For instance, I have one dataset that is 993x1 and the other 66x1. I want to show that that smaller dataset (the line graph) is similar to the larger dataset (the bar graph).
Does anyone have any suggestions on how to do this?
Thanks!
0 commentaires
Réponse acceptée
Chad Greene
le 4 Avr 2016
Modifié(e) : Chad Greene
le 4 Avr 2016
Here are two distributions, x1 and x2:
x1 = randn(993,1);
x2 = randn(66,1);
hist(x1,-5:.5:5)
hold on
h = hist(x2,-5:.5:5);
plot(-5:0.5:5,h,'r-','linewidth',2)

Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!