MATLAB: Superimposing two imagesc graphs over each other.

axiscolor gradingcolor scaledcolorbarcolourcolour scaledimagescplotsimulationsuperimposed graphssurf

I have a matrix P which varies with time t,
P(:, :, t) ;
a variable Pmax,
Pmax = max(max(P(;,:,t)));
which I visualise through imagesc, step by step to create an animation:
figure
for i = 1:10:1000
imagesc(P(:, :, i), [0, Pmax]);
axis square
colorbar
end
I have another variable B, which I would like to visualise superimposed over the first imagesc plot, in a different colorbar/colour grading as P.
How could this be achieved? I was thinking of using a surf plot viewed from above instead (the two plots would be 2D, and the view set directly above to seem as a 2D plot). However to achieve this through the imagesc command would be much better.
Please share any ideas below, thank you!

Best Answer

It is difficult to give exact solution without the exact data. But, below is an example of how you can superimpose 2 data using imagesc with different transparency & colormap.
%plot first data
ax1 = axes;
im = imagesc(ax1,imread('cameraman_512.png'));
im.AlphaData = 0.5; % change this value to change the background image transparency
axis square;
hold all;
%plot second data
ax2 = axes;
im1 = imagesc(ax2,imread('fighter.png'));
im1.AlphaData = 0.5; % change this value to change the foreground image transparency
axis square;
%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,'summer')
colormap(ax2,'winter')
%set the axes and colorbar position
set([ax1,ax2],'Position',[.17 .11 .685 .815]);
cb1 = colorbar(ax1,'Position',[.05 .11 .0675 .815]);
cb2 = colorbar(ax2,'Position',[.88 .11 .0675 .815]);
cameraman_512.png
fighter.png
overlap.png