How to plot scatter graph with colourmap functon
Afficher commentaires plus anciens
Hi,
I have this 3 column matrix, where:
column 1 = x values
column 2 = y values
columnn 3 = value of each given point
myVal = [0 21 1.07 ;
0 60 0.51 ;
0 81 0.74 ;
0 102 0.84 ;
0 151 0.96 ;
0 201 1.26 ;
0 300 1.08 ;
0 387 1.31 ;
0 501 1.44 ;
0 589 1.4 ;
0 693 1.39 ;
0 792 1.25 ;
0 889 1.16 ;
0 990 1.07 ;
0 1185 1.21 ;
0 1384 1.14 ;
0 1582 1.44 ;
0 1778 1.42 ;
0 1976 0.69 ;
0 2466 1.04 ;
0 2957 1.64 ;
0 3201 0.94 ;
0 3521 0.82 ;
48.8 19 1.01 ;
48.8 37 0.37 ;
48.8 50 0.47 ;
48.8 75 0.63 ;
48.8 99 0.75 ;
48.8 119 0.57 ;
48.8 137 3.04 ;
74.8 21 0.73 ;
74.8 39 0.34 ;
74.8 71 0.52 ;
74.8 149 0.6 ;
74.8 200 0.89 ;
74.8 300 0.56 ;
74.8 398 0.74 ;
74.8 496 0.81 ;
74.8 596 0.86 ;
74.8 694 1.03 ;
74.8 792 0.85 ;
282.7 15 0.12 ;
282.7 54 0.19 ;
282.7 80 0.18 ;
282.7 100 0.24 ;
282.7 199 0.29 ;
282.7 497 0.56 ;
282.7 695 0.76 ];
How would I adapt this data to work for this scatter heatmap function:
cmap = jet(256); %state colourmaop
v = rescale(myVal, 1, 256);
numVal = length(myVal)
markerColors = zeros(numVal, 3)
% Now assign marker colors according to the value of the data.
for k = 1 : numVal
row = round(v(k));
markerColors(k, :) = cmap(row, :);
end
% Create the scatter plot.
scatter(x, y, [], markerColors);
grid on;
Charlie
3 commentaires
KSSV
le 3 Déc 2020
x = myVal(:,1) ;
y = myVal(:,2) ;
z = myVal(:,3) ;
scater(x,y,[],z,'filled')
colorbar
Charlie Hillary
le 3 Déc 2020
Charlie Hillary
le 3 Déc 2020
Réponse acceptée
Plus de réponses (1)
Bjorn Gustavsson
le 3 Déc 2020
Modifié(e) : Bjorn Gustavsson
le 3 Déc 2020
To make it short and simple couldn't you just use scatter and let it automatically scale the values?
scatter(x,y,23,myVal,'filled')
colormap(jet(256))
1 commentaire
Charlie Hillary
le 3 Déc 2020
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects 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!