How do I overlay contour plots with a different color map for each overlay

19 views (last 30 days)
I have been able to overlay contours using Matlab 2012b (see the example below) using freezecolors to allow each overlay to have a constant color that is different than the other overlays. But in 2015b freezecolors no longer works. According to this, I shouldn't need freezecolors anymore: http://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors---unfreezecolors
So I found this, but can't get it to work for what I am trying to do:
Any help to get this to work in 2015b would be greatly appreciated!!!
  1 Comment
Carl
Carl on 3 Apr 2017
Hi Robert, can you clarify why the second link you posted does not work for you? It seems that you should be able to overlay your contour plots, each on a separate axes with a different colormap.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 4 Apr 2017
Z = peaks(100) ;
% plot valaues 1
figure
hold on
colors = {'r' 'b' 'g' 'y' 'm' 'k' 'c' 'g' 'r' 'k'} ;
for i = 1:10
contour(Z,[i i],colors{i},'ShowText','on') ;
end
  6 Comments
Robert
Robert on 5 Apr 2017
Sorry, the code should look like this:
nMdls = 2;
Axes = zeros(nMdls);
Axes(1) = axes;
%%Create the first axis and plot the contours
[x,y,z] = peaks;
hold 'on'
for i = 1:2:10
contour(Axes(1),x,y,z, [i, i],'r', 'ShowText', 'on')
end
%%Create the second axis and plot the contours
Axes(2) = axes;
z2 = z * 1000; %Change the order of magnitude of the orignal z-data
hold 'on'
for i = 2000:2000:10000
contour(Axes(2),x,y,z2, [i, i],'b', 'ShowText', 'on');
end
linkaxes(Axes)
%%Hide the top axes
set(Axes(2), 'visible', 'off');
set(Axes(2), 'XTick', []);
set(Axes(2), 'YTick', []);

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!