Filter löschen
Filter löschen

imagesc() contour superposition

11 Ansichten (letzte 30 Tage)
Articat
Articat am 23 Okt. 2019
Beantwortet: Subhadeep Koley am 29 Okt. 2019
Hi,
I am trying to plot a contour plot over an imagesc() plot.
I have the following code:
figure,
subplot(1,3,1);
xVal = 5;
[xSlVal,xSlice] = min(abs(xVal - xGrid2(1,:,1)));
norm_jet_xVeloc = velocityMag(:,xSlice,:)./max(max(max(velocityMag)));
veloc_mag_conotur = velocityMag(:,xSlice,:)./u;
imagesc(squeeze(zGrid2(:,1,1)),squeeze(yGrid2(1,1,:)),squeeze(norm_jet_xVeloc));
hold on
C = contour(squeeze(zGrid2(:,1,11)),squeeze(yGrid2(1,1,:)),squeeze(veloc_mag_conotur));
caxis([-0.5 0.5]);
colormap('gray');
set(gca,'YDir','normal');
pbaspect([6 40 1]);
xlim([ -3 3]);
ylim([ 0 40]);
xlabel('z (mm)');
ylabel('y (mm)');
I think that it is working however I can't see the contour lines over the imagesc() magnitude plot. Is there another way to plot contour for a different color?
Thanks for your help.
  1 Kommentar
Robert U
Robert U am 24 Okt. 2019
Please provide the data that is necessary to reproduce your plot.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Subhadeep Koley
Subhadeep Koley am 29 Okt. 2019
It is difficult to provide exact solution without the exact data but the following is a demo code which superimposes a contour() plot over an imagesc() plot while assigning different colormaps to each of them.
% Plot first data
ax1 = axes;
imagesc(ax1,imread('cameraman.tif'));
axis square; hold all;
% Plot second data
ax2 = axes;
contour(ax2,imread('cameraman.tif'));
axis square; hold off;
% Only to reverse the y axis,
set(ax2,'ydir','reverse')
% Link axes
linkaxes([ax1,ax2])
% Hide the top axes
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
% Add differenct colormap to different data if you wish
colormap(ax1,'gray'); % Colormap for the imagesc plot
colormap(ax2,'hsv'); % Colormap for the contour plot
contourOverImagesc.png

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by