How do I keep the number of bins used the same when generating a histogram along with how do I illustrate its depth with color?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andrew Stark
le 26 Nov 2020
Réponse apportée : Walter Roberson
le 26 Nov 2020
%Plotting Histogram
for i=1:3000
Zf2=Zf{i,1};
Df2=Df{i,1};
H=[Df2,Zf2];
hist3(H,[10 10])
hold on
end
I am trying to generate a histogram and when set to 1 iteration it generates this histogram
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/430198/image.jpeg)
when set to 2 iterations it generates this histogram
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/430203/image.jpeg)
How do I keep the number of bins the same and use color to illustrate the depth of the histogram?
0 commentaires
Réponse acceptée
Walter Roberson
le 26 Nov 2020
You are keeping the number of bins the same for the two histograms. The bins just are not aligned between the two plots, and you are using "hold on"
Remember that when you specify by number of bins, it takes the range of data and subdivides it into the given number of bins. When you have two different plots with different ranges, then the edges are not going to align.
You should be considering specifying bin centers or bin edges instead of numbers of bins.
For coloring use 'CDataMode', 'auto', 'FaceColor', 'interp'
0 commentaires
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!