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?

2 vues (au cours des 30 derniers jours)
%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
when set to 2 iterations it generates this histogram
How do I keep the number of bins the same and use color to illustrate the depth of the histogram?

Réponse acceptée

Walter Roberson
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'

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by