Variable marker size scatter plot

21 vues (au cours des 30 derniers jours)
Xavier Simón Montero
Xavier Simón Montero le 5 Déc 2022
I am trying to create an scatter plot as shown below from a regular scatter plot.
The objetive is that the size of the marker corresponding to a certain area becomes dependant of the number of points in that area.
Does anybody know how to do this?

Réponse acceptée

Steven Lord
Steven Lord le 5 Déc 2022
The size input argument to the scatter function can be a scalar or an array of the same size as the coordinate data. In the example below the marker at coordinates (10, 100) is much larger than the marker at coordinates (1, 1).
x = 1:10;
y = x.^2;
scatter(x, y, 2*y)
  3 commentaires
Steven Lord
Steven Lord le 5 Déc 2022
Ah, so the problem you're trying to solve is how to bin the data to generate the array of marker sizes? I think the histcounts2 function will help you with that task.
Xavier Simón Montero
Xavier Simón Montero le 7 Déc 2022
Thank you, this has worked

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by