
How to plot two histograms: one line over another bar?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Josh
el 4 de Abr. de 2016
Comentada: Josh
el 4 de Abr. de 2016
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 comentarios
Respuesta aceptada
Chad Greene
el 4 de Abr. de 2016
Editada: Chad Greene
el 4 de Abr. de 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)

Más respuestas (0)
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!