![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233379/image.jpeg)
Normalization of colorbar showing bincounts of binscatter
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233355/image.png)
x=rand(1,10000);
y=rand(1,10000);
binscatter(x,y,[100,100])
colormap(gca,'jet')
0 Commenti
Risposta accettata
Adam Danz
il 9 Ago 2019
Modificato: Adam Danz
il 12 Ago 2019
I would use histcounts2() to determine the density within each bin. Then you can normalize those data and send it into histogram2(). See comments within the code below for details.
x=rand(1,10000);
y=rand(1,10000);
% compute bin counts
[binCounts, xbin, ybin] = histcounts2(x,y,[100,100]);
% Normalize bin counts to 0:1
binCountsNorm = (binCounts - min(binCounts(:))) ./ range(binCounts(:));
% Plot the results *
histogram2('XBinEdges',xbin,'YBinEdges',ybin,'BinCounts',binCountsNorm, ...
'DisplayStyle','tile','ShowEmptyBins','on') % or you may what "off"
% Add color bar and make sure the color ranges from 0:1
colorbar()
caxis([0,1])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233379/image.jpeg)
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Distribution Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!