How to change the color map manually.
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jotheeshwar V
le 21 Juin 2018
Commenté : Walter Roberson
le 23 Juin 2018
I have tried changing the colourmap in the Figures interface.
The change has been reflected only in the legend bar, not in the plot.
I am plotting grid plot along X (2634x1) and Z (512x1) axes with series of Y (512x2634) values which has to be plotted in colour map.
The Code follows.
>> load X.txt
>> load Y.txt
>> load Z.txt
>> [Z_grid, X_grid] = ndgrid(Z, X);
>> geoshow(Z_grid, X_grid, Y);
After this, the figure Dialog box pops up.
In that, I have tried to change the colourmap using menu. but, the changes are not reflected in the plot.
Kindly, help me out of this.
Regards,
Jotheeshwar Velayudham
0 commentaires
Réponse acceptée
Walter Roberson
le 21 Juin 2018
geoshow() and mapshow() appear to invoke the internal function mappolygon() (at least for some geometries.)
mappolygon() creates patches that have [1 1 0.5] hard-coded as the default face color.
That is, at least for some kinds of input, the patches that are created have RGB face colors and therefore are not affected by changes to the colormap.
To change the color of faces, you need to create a symbolize structure and pass it in, specifying the color for each type of item.
3 commentaires
Walter Roberson
le 23 Juin 2018
geoshow() creates one graphics object. legend only creates one entry for each graphics object.
The trick is to use something like,
state_names = {'very bad', 'kinda bad', 'not so good', 'okay', 'good', 'better', 'best'};
hold on
h = arrayfun(@(idx) plot(nan, nan, 'Color', cmap(idx, :), 'DisplayName', state_names{idx}), 1:length(state_names));
legend(h, 'show');
hold off
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Colormaps 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!