Make distribution visible in scatter plots

2 vues (au cours des 30 derniers jours)
Joel Schelander
Joel Schelander le 17 Mai 2021
Modifié(e) : Adam Danz le 17 Mai 2021
I have two vectors, I3 and D, of the size 1000000x1. They are plotted against each other in a scatter plot (see PIplot1)
I want to know how many values I have. For example If you look to the far right of the figure. I dont know How many values are around y=50 or how many are around y=150.
I need to make the distribution visible somehow, but I do not know how to go about it.
plot(I3,D,'.','Color', [0 0.4470 0.7410]);

Réponse acceptée

Adam Danz
Adam Danz le 17 Mai 2021
Modifié(e) : Adam Danz le 17 Mai 2021
You can display the 2D binned density using histogram2.
Demo: The plot on the left and right contain the same data.
x = 1:105;
ym = randn(800, numel(x)) .* linspace(2,35,numel(x)) + linspace(6,150,numel(x)) ;
xm = repmat(x,size(ym,1),1);
figure()
tiledlayout(1,2)
ax(1) = nexttile;
plot(x,ym,'b.')
grid on
axis tight
ax(2) = nexttile;
histogram2(xm,ym,'DisplayStyle','tile')
axis tight
cb = colorbar();
ylabel(cb, 'bin count')
linkaxes(ax)
Also try setting BinMethod or or bin edges in histogram2.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by