Create a specific colormap for a contour plot
56 views (last 30 days)
Show older comments
Hi I am trying to create a contour plot with my own colormap. However, this only works up to a certain value, after which the colours are no longer output as I had hoped. From 36.8 on, everything is output in the same colour. Does anyone know why this happens?
Levels = [3200 3366 3566 3680 3700 3800]
num_points = diff(Levels);
colors = [ 0.24 0.36 0.56;
0.25 0.56 0.55;
0.45 0.82 0.26;
0.82 0.8 0.19;
0.81 0.61 0.24;
];
map = [];
for i=1:numel(num_points)
map = [map; repmat(colors(i,:), num_points(i), 1)];
end
figure( 'Name', 'untitled fit 1' , 'Colormap', map);
h = plot( fitresult, [xData, yData], zData, 'Style', 'Contour' );
set(h,'LevelList',[23.4 33.6 35.6 36.8 37.0 40] , 'ShowText', 'on')
0 Comments
Answers (1)
Kevin Holly
on 18 Oct 2021
Type "colorbar" in the command window to view the colorbar. You can then see the limits of the colormap. You can change the limits with caxis.
Alternatively, you can Select Edit>Colormap... under the Figure menu and set the colormap limits with the Colormap Editor.
2 Comments
Kevin Holly
on 19 Oct 2021
What version of MATLAB are you using? caxis has been around since before 2006. How are you using the function?
Did you enter the min and max limits as such?
caxis([0 100])
What was the range of your colormap?
See Also
Categories
Find more on Colormaps 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!