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!

回答 (2 件)

KSSV
KSSV 2021 年 10 月 11 日
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 件のコメント

Yu Qin
Yu Qin 2021 年 10 月 12 日
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.
KSSV
KSSV 2021 年 10 月 12 日
You try out with the given code.....if it doesn't work, let me know.
Yu Qin
Yu Qin 2021 年 10 月 12 日
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.

サインインしてコメントする。

yanqi liu
yanqi liu 2021 年 11 月 5 日
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;

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

質問済み:

2021 年 10 月 11 日

回答済み:

2021 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by