Hello community
I am trying to plot earthquakes. I would like to plot them using circles, which size is scaled with their magnitude and at the same time I would like to color them regarding the value of the depth. And, I want to represent them in the legend. Like the adjoint image.
I was trying with scatter, it works, if I do a "scaling/normalization" to the magnitude and then I can fill the circles with a color based on depth, but I do not know how to show the legend using the size of circles.
Another idea that I saw on this forum was the use of index, they scale perfectly the size of the circle, but how can I color them? and how can I plot the size of the circles on the legend?
Please, If someone has any suggestion or comment I would like to hear
Thanks

 Respuesta aceptada

Star Strider
Star Strider el 6 de Abr. de 2021

1 voto

The third argument to scatter will vary the circle sizes according to whatever variable vector is specified, and the fourth argument the colours.
I do not have the Mapping Toolbox, however the scatterm function may be best in that context.

4 comentarios

Perez Danny
Perez Danny el 6 de Abr. de 2021
Hello Star Strider, thanks for your response....I'll try scatterm to see the which is better for what I want to do.
In fact I have already did it using index, I took it from a previous question of this forum. At moment scatter works well, but then my next doubt is how can I put on the legend circle sizes (not all, only representative sizes that means if 0<=magnitude<=3 the size of the circle is 5, if 3<magnitude<=6 the size of the circle is 50 and if 6<magnitude<=9 the size of the circle is 100. Well, in fact I guess I am ansxering my question, that could be done by a foor loop, but that I do not get is how I can show these 3 sizes in the legend
Star Strider
Star Strider el 6 de Abr. de 2021
As always, my pleasure!
Using a loop with the hold function is likely the easiest. Each scatter (or scatterm, that I assume works similarly to scatter) call should be with a handle referring to it, so those colours will all show up appropriately in the legend. (The makrers in the legend will all be the same size.)
One possible approach:
NrEarthquakes = 10;
cm = colormap(jet(NrEarthquakes));
figure
hold on
for k = 1:NrEarthquakes
hs{k} = scatter(rand(1,2), rand(1,2), k*25, cm(k,:), 'filled');
end
hold off
grid
legend([hs{:}], compose('Earthquake %.1f', 1:NrEarthquakes), 'Location','best')
axis([0 1 0 1])
% axis('equal')
Experiment to get different results.
Perez Danny
Perez Danny el 6 de Abr. de 2021
That approximation is also nice, and easier to understand.
Thanks so much for your time and assistance
Star Strider
Star Strider el 7 de Abr. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 6 de Abr. de 2021

Comentada:

el 7 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by