How to plot scattered data YZ with diffrent color for each slice X of 3 dim matrix XYZ

조회 수: 1 (최근 30일)
How to plot scattered data YZ with diffrent color for each slice X of 3 dim matrix XYZ ?
There are two F1 F2 matrices (3 dimensional) with same dimensions.
scattered plot scatter(F1(:), F2(:)) will plot all the data with same color.
I would like slice 'k' index in one of the dimensions (let say X) to be colored with same color and the color to change for the values of k.
the code below works however if has two loops .
n = [1:1:10]; % X
m = [1:1:3]; % Y
z1 = rand(1,20);
z2 = rand(1,20);
zr1 = reshape(z1,1,1,[]); % Z
zr2 = reshape(z2,1,1,[]); % Z
F1 = meshgrid(n,m).*zr1; %XYZ
F2 = meshgrid(n,m).*zr2; %XYZ
C = jet(length(n))
for en = 1:length(n)
for pll = 1:length(m)
scatter(reshape(F1(pll,en,:),1,[]),reshape(F2(pll,en,:),1,[]),[],C(en,:)); % ? on one plot with different collor for slices in x
hold on
end
end

답변 (1개)

Adam Danz
Adam Danz 2020년 7월 12일
편집: Adam Danz 2020년 7월 15일
I think you're describing this.
Cfull = repmat(repelem(C,size(F1,1),1),size(F1,3),1);
scatter(F1(:),F2(:),40,CFull,'filled')

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by