A question about adjustment the Histogram2 Properties

9 views (last 30 days)
Hello all, Do you know how to:
A: Delete the black line around each square of left side figure ( to be similar to the right side figure)
B: change the square size of left side figure to the size of the right side figure?
Here is my script to generate both of these figures, for two different datasets:
Rights side figure:
h = histogram2(X,Y,'DisplayStyle','tile','ShowEmptyBins','off');
colormap turbo(40)
caxis([10,90])
xlim([0 500])
ylim([0 500])
Left side figure:
h = histogram2(X,Y,'DisplayStyle','tile','ShowEmptyBins','off');
colormap turbo(40)
caxis([10,90])
xlim([0 1000])
ylim([0 1000])

Accepted Answer

Dave B
Dave B on 8 Dec 2021
Edited: Dave B on 8 Dec 2021
For the first bit, you can set the EdgeColor to 'none'.
For the second bit, getting 'squares' depends on both the fact that bins that you've used for the histogram and the aspect ratio of your axes. If you use equal sized bins and axis equal, you should be in good shape. To adjust the size of the bins, just specify the values for the bin edges:
x=randn(10000,1);
y=x+randn(10000,1);
xbins=linspace(-5,5,30);
ybins=linspace(-5,5,30);
histogram2(x,y,xbins,ybins,'DisplayStyle','tile','EdgeColor','none')
grid off
axis equal

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!