How to plot multiple 2D matrix data with different color on the same figure?
Show older comments
Hi,
I have multiple 200x100 data matrixes, and I want to plot them on the same figure with different color. It is similar as hold on with plot function except I want to display them similar as image. Normally I use imagesc to plot these matrixes data and hold on just doesn't work since the final imgae I get is the last data matrix.
The data output on the figure is similar as follwoing:

Thanks for helping me!
Answers (2)
I = rand(100,100,10) ;
[m,n,p] = size(I) ;
[Y,Z] = meshgrid(1:n,1:n) ;
X = ones(m,n) ;
figure
hold on
for i = 1:p
surf(i*X,Y,Z,I(:,:,i))
end
shading interp
view(13,24)
clear all; close all; clc;
im1 = imread('cameraman.tif');
im2 = imread('rice.png');
figure;
h1 = imagesc(im1);
set(h1, 'AlphaData', 0.8)
hold on;
h2 = imagesc(im2);
set(h2, 'AlphaData', 0.2)
axis equal;
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

