A question about adjustment the Histogram2 Properties

8 vues (au cours des 30 derniers jours)
BN
BN le 8 Déc 2021
Commenté : BN le 8 Déc 2021
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])

Réponse acceptée

Dave B
Dave B le 8 Déc 2021
Modifié(e) : Dave B le 8 Déc 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

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by