How to plot scattered data YZ with diffrent color for each slice X of 3 dim matrix XYZ
1 view (last 30 days)
Show older comments
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
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!