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

2 ビュー (過去 30 日間)
Ole
Ole 2020 年 7 月 12 日
編集済み: Adam Danz 2020 年 7 月 15 日
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 Center および File ExchangeScopes and Data Logging についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by