Color scale of scatter plot?
Afficher commentaires plus anciens
Hi! That's my problem: I have datas like this images, the red dot is a wheater station, the blue dots are lightnings, in the axies there are the lat/lon coordinates.

For each lightning I have associated a value (weight) that decrease from the station (in correspondence of this point there is 1) to the the farthest lightning ( ~0). I need that the colour of the dots changes gradually from dark blue (near the station) to light blue (the farthest lightning).
The matrix of the data is 1480x4 (first column -> datenum of the lightning, second and third columns -> coordinates, fourth column -> weight value of the lightning).

The actual code is:
scatter(longitude_lightnings,latitude_lightnings,6,'filled')
scatter(longitude_station,latitude_station,'filled')
Someone can help me? Thanks!
Réponse acceptée
Plus de réponses (1)
x = randn(100, 1);
y = randn(100, 1);
cmap = parula(512);
cmap = cmap(1:360, :); % dark blue to green (360 colors)
pos_station = [0 0];
c = sqrt((x-pos_station(1)).^2 + (y-pos_station(2)).^2);
c = (c-min(c))/(max(c)-min(c))*359+1; % map to 360 colors
scatter(x,y,[],c, 'filled');
colormap(cmap)
colorbar
1 commentaire
Martina Bonsignore
le 30 Nov 2021
Catégories
En savoir plus sur Blue dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

