Why do the colors in the color bar of a "contourfm" plot get non-uniformly distributed over the updated range of color axis, when I update the color axis limits using "caxis"?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 21 Jan 2016
Answered: MathWorks Support Team
on 21 Jan 2016
Execute the following commands to generate a contour map:
>> figure
>> axesm eckert4; framem; gridm; axis off; tightmap
>> load geoid
>> contourfm(geoid, geoidrefvec, -120:20:100, 'LineStyle', 'none');
>> coast = load('coast');
>> geoshow(coast.lat, coast.long, 'Color', 'black')
>> contourcbar
Now update the color axis limits to a wider range, [-300 300], by executing the following command
>> caxis([-300 300])
The colors on the color bar get non-uniformly distributed over the updated range of color axis.
How can these colors be distributed uniformly over the updated range of color axis?
Accepted Answer
MathWorks Support Team
on 23 Feb 2016
The colors can be distributed uniformly on the color bar by specifying the wider range of the color axis limit within the "contourfm" command as follows:
>> contourfm(geoid, geoidrefvec, -300:20:300, 'LineStyle', 'none');
This will ensure a uniform distribution of colors on the color bar when the color axis limits are updated to [-300 300].
Now use "caxis" to change the color axis limits to [-300 300]. It will update both the color bar and the plot accordingly.
>> caxis([-300 300])
Also, if a wider range of colors is needed, an appropriate color map can be used, e.g., "jet" can be used by executing the following command:
contourcmap jet
0 Comments
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!