Create a specific colormap for a contour plot

44 次查看(过去 30 天)
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')

回答(1 个)

Kevin Holly
Kevin Holly 2021-10-18
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 个评论
Cb
Cb 2021-10-18
Hi Kevin, thanks for replying!
The caxis version doesn't seem to work.. And you seem to be using a different version of Matlab because I can see the colormap editor but it looks very different and I can't change the size and colorspace.
Do you maybe have another idea?
Kevin Holly
Kevin Holly 2021-10-19
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by