# How to plot contour on imagesc for three variables?

2 views (last 30 days)
Wiqas Ahmad on 11 Apr 2022
Commented: Wiqas Ahmad on 12 Apr 2022
I want to obtain the folllowing figure using the program mentioned below. The three variable red encircled can be placed as x,y,z-axis. How can I modify my program to get such like figure? close all;
clear all;
clc;
%% ------------------------------Program-------------------------------------
EC = [0.0052 0.0078 0.0104 0.0130 0.0156 0.0182 0.0208 0.0234 0.0260 0.0286];
Reff =[4:1:20];
FOV=[1,2];
for i=1:length(FOV)
for j = 1:length(EC)
for k = 1:length(Reff)
I(:,j)= smooth(sum(I0,2));
Q(:,j)= smooth(sum(Q0,2));
if(i==1)
dep1(:,j)= (I(:,j)-Q(:,j))./(I(:,j)+Q(:,j));
plot(dep1(:,j),z,'LineWidth',1.5,'color',col(:,j));
end
if(i==2)
dep2(:,j)= (I(:,j)-Q(:,j))./(I(:,j)+Q(:,j));
plot(dep2(:,j),z,'LineWidth',1.5,'color',col(:,j));
end
imagesc(num2str(Reff(k)),num2str(EC(j)),depi(j,k).')
colorbar
end
end
end
figure('name','depolarization ratio')
hold on
contour(Reff,EC,depi')
hold on
imagesc(Reff,EC,depi')
colorbar

Bjorn Gustavsson on 11 Apr 2022
Maybe it is enough for you to make this minor modification:
figure('name','depolarization ratio')
imagesc(Reff,EC,depi')
hold on
c_levels = (15:5:65)/1000; % Your contour-levels might be completely different
[c,h] = contour(Reff,EC,depi',c_levels,'k'); % make contours black - to not get the same colours as the imagesc-map
clabel(c,h)
colorbar
HTH
##### 1 CommentShowHide None
Wiqas Ahmad on 12 Apr 2022
Thank you so much.