How can I plot coordinates with different colours based on the value and family of my variables ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How can I associate a colour to a coordinate depending on the family of its highest associated value ?
For example, if my coordinates are X=[2 4 -3 5 6] and Y=[4 9 1 -2 1] and my associated values are L1 (blue) =[1 1 1 1 1], L2 (green) =[2 1 2 1 2], L3 (red) =[3 3 3 3 1] and L4 (purple) =[10 0 2 0 0], I want the coordinate (2,4) to be purple, the coordinate (4,9) to be red, the coordinate (-3 1) to be red and so on.
The main objective is to make a "phase diagram" that tell us which treatment between L1, L2, L3 and L4 is the most optimal (has the highest value) for each point in space.
0 commentaires
Réponse acceptée
Simon
le 15 Nov 2013
Hi!
X = [2 4 -3 5 6];
Y = [4 9 1 -2 1];
L1 = [1 1 1 1 1];
L2 = [2 1 2 1 2];
L3 = [3 3 3 3 1];
L4 = [10 0 2 0 0];
% concat all L1 to L4
L = [L1; L2; L3; L4];
% sort columns ascending
[~, ix] = sort(L, 1);
% last row of ix is the L1 to L4 index, we don't need the rest
ix = ix(end, :);
% color specification
col = {[1 0 0], [0 1 0], [0 0 1], [0 0.5 0.8]};
% plot
figure(1); cla; hold on;
for n = 1:length(X)
plot(X(n), Y(n), 'Color', col{ix(n)}, 'Marker', 'o');
end
You may define your colors as RGB values in the range [0; 1].
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!