How to change the color map manually.
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jotheeshwar V
am 21 Jun. 2018
Kommentiert: Walter Roberson
am 23 Jun. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Jun. 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 Kommentare
Walter Roberson
am 23 Jun. 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
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!