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 次查看(过去 30 天)
%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?

采纳的回答

Walter Roberson
Walter Roberson 2020-11-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by