How to set explicit contour plot colors for specific value ranges
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Batyrkhan Tokmyrza
le 13 Mar 2020
Modifié(e) : Ameer Hamza
le 14 Mar 2020
Is it possible to set plot colors for specific value ranges?

I have defined the colormap as follows:
map = [0 1 0;
0 1 1;
0 0 1;
0 0.5 1;
1 1 1;
1 1 0.5;
1 1 0;
1 0.5 0;
1 0 0];
colormap(map);
caxis([-1 1]);
Can the colormap be somehow tied to the value ranges given in the table?
0 commentaires
Réponse acceptée
Ameer Hamza
le 14 Mar 2020
Modifié(e) : Ameer Hamza
le 14 Mar 2020
You will need to create a map matrix where the number of rows of a specific color is directly proportional to the length of its interval. Try this
Levels = [-8 -7 -5 -3 -1 1 3 5 7 8]/8;
num_points = diff(Levels)*8; % multiplied by 8 so that after scaling all elements will be integers
colors = [0 1 0;
0 1 1;
0 0 1;
0 0.5 1;
1 1 1;
1 1 0.5;
1 1 0;
1 0.5 0;
1 0 0];
map = [];
for i=1:numel(num_points)
map = [map; repmat(colors(i,:), num_points(i), 1)];
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Color and Styling dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!