3D plot, draw (X,Y,Z,value)

4 views (last 30 days)
Mohamed Nafea
Mohamed Nafea on 27 Aug 2022
Edited: Chunru on 28 Aug 2022
how to performe a plot like contours (X,Y,Z,Value)
I have a set of data
for example
(1,1,1)=5
(1,1,2)=7
(1,2,1)=6
i want to plot it like a 3D with legend
Sample for the data
X Y Z Value
1 1 0.000 1.000
1 1 0.005 2.000
1 1 0.010 3.000
1 1 0.015 4.000
1 1 0.020 5.000
1 1 0.025 6.000
1 2 0.000 7.000
1 2 0.005 8.000
1 2 0.010 9.000
1 2 0.015 10.000
1 2 0.020 11.000
1 2 0.025 12.000
i 3 0.000 13.000
1 3 0.005 14.000
1 3 0.010 15.000
1 3 0.015 16.000
1 3 0.020 17.000
1 3 0.025 18.000
2 1 0.000 19.000
2 1 0.005 20.000
2 1 0.010 21.000
2 1 0.015 22.000
2 1 0.020 23.000
2 1 0.025 24.000
2 2 0.000 25.000
2 2 0.005 26.000
2 2 0.010 27.000
2 2 0.015 28.000
2 2 0.020 29.000
2 2 0.025 30.000
2 3 0.000 31.000
2 3 0.005 32.000
2 3 0.010 33.000
2 3 0.015 34.000
2 3 0.020 35.000
2 3 0.025 36.000
  2 Comments
Star Strider
Star Strider on 27 Aug 2022
This does not make sense to me.
I’m posting this in the event someone else may have some insight into it —
xyzv = [ 1 1 0.000 1.000
1 1 0.005 2.000
1 1 0.010 3.000
1 1 0.015 4.000
1 1 0.020 5.000
1 1 0.025 6.000
1 2 0.000 7.000
1 2 0.005 8.000
1 2 0.010 9.000
1 2 0.015 10.000
1 2 0.020 11.000
1 2 0.025 12.000
1 3 0.000 13.000
1 3 0.005 14.000
1 3 0.010 15.000
1 3 0.015 16.000
1 3 0.020 17.000
1 3 0.025 18.000
2 1 0.000 19.000
2 1 0.005 20.000
2 1 0.010 21.000
2 1 0.015 22.000
2 1 0.020 23.000
2 1 0.025 24.000
2 2 0.000 25.000
2 2 0.005 26.000
2 2 0.010 27.000
2 2 0.015 28.000
2 2 0.020 29.000
2 2 0.025 30.000
2 3 0.000 31.000
2 3 0.005 32.000
2 3 0.010 33.000
2 3 0.015 34.000
2 3 0.020 35.000
2 3 0.025 36.000 ];
Xm = reshape(xyzv(:,1),6,[])
Xm = 6×6
1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2
Ym = reshape(xyzv(:,2),6,[])
Ym = 6×6
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
Zm = reshape(xyzv(:,3),6,[])
Zm = 6×6
0 0 0 0 0 0 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0150 0.0150 0.0150 0.0150 0.0150 0.0150 0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.0250 0.0250 0.0250 0.0250 0.0250 0.0250
Vm = reshape(xyzv(:,4),6,[])
Vm = 6×6
1 7 13 19 25 31 2 8 14 20 26 32 3 9 15 21 27 33 4 10 16 22 28 34 5 11 17 23 29 35 6 12 18 24 30 36
figure
surf(Xm,Ym,Zm)
colormap(turbo(5))
.
dpb
dpb on 27 Aug 2022
Perhaps @John D&#39;Errico's <HighDimensionalPlottingIssues> will be of some conceptual benefit to the poster...

Sign in to comment.

Answers (1)

Chunru
Chunru on 28 Aug 2022
Edited: Chunru on 28 Aug 2022
You can use scatter3 with marker size/color to represent value, though it is not a contour.
xyzv = [ 1 1 0.000 1.000
1 1 0.005 2.000
1 1 0.010 3.000
1 1 0.015 4.000
1 1 0.020 5.000
1 1 0.025 6.000
1 2 0.000 7.000
1 2 0.005 8.000
1 2 0.010 9.000
1 2 0.015 10.000
1 2 0.020 11.000
1 2 0.025 12.000
1 3 0.000 13.000
1 3 0.005 14.000
1 3 0.010 15.000
1 3 0.015 16.000
1 3 0.020 17.000
1 3 0.025 18.000
2 1 0.000 19.000
2 1 0.005 20.000
2 1 0.010 21.000
2 1 0.015 22.000
2 1 0.020 23.000
2 1 0.025 24.000
2 2 0.000 25.000
2 2 0.005 26.000
2 2 0.010 27.000
2 2 0.015 28.000
2 2 0.020 29.000
2 2 0.025 30.000
2 3 0.000 31.000
2 3 0.005 32.000
2 3 0.010 33.000
2 3 0.015 34.000
2 3 0.020 35.000
2 3 0.025 36.000 ];
% Use scatter3
scatter3(xyzv(:,1), xyzv(:,2), xyzv(:,3), xyzv(:,4), xyzv(:,4))
colorbar

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!