How to plot multiple 2D matrix data with different color on the same figure?

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)

3 Comments

Thanks for replies. Let me clear my purpoese. As you can see from the figure that my plot with imagesc has multiple dots. This data is non-zero value. I want to plot another matrix value on the same image with different color of dots. For example, data1's dots color is yellow, and data2 is red. In this case, I can recoginize the differences of each dataset.
You try out with the given code.....if it doesn't work, let me know.
Thanks KSSV. The output of this code is not my expected results. Check the following painting.
I have two dataset, I want plot them on the same figure so I can recognize the shif from data1 to data2. The red dot would come from dataset 2. This is my expected results.

Sign in to comment.

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

Asked:

on 11 Oct 2021

Answered:

on 5 Nov 2021

Community Treasure Hunt

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

Start Hunting!