Filter löschen
Filter löschen

Scatter3, insert dashed line downwards, and sideways

6 Ansichten (letzte 30 Tage)
Joel
Joel am 6 Okt. 2016
Kommentiert: Joel am 6 Okt. 2016
I want to show my data in a scatter3 plot.
However, the way the data is shown, it is not very clear where exactly on the 3 axis the data points are.
An example,
figure;
x = 0.9914;
y = 0.0390;
z = 20
scatter3(x,y,z,'filled')
view(-30,10)
What I would like to do is to draw a dashed line straight downwards from the point, so that it is clearer where the point is on the XY plane. Also, I would like to draw a dashed line from the point to the Z axis, so that it is clear where the point is on the Z axis plane.
If this turns out to be too messy I will look at a way to write the XYZ values for each point just above each point.

Akzeptierte Antwort

Giovanni Mottola
Giovanni Mottola am 6 Okt. 2016
Here I assumed x, y, z are vectors of length "len".
To draw a line joining each scatter point to the horizontal plane use:
hold on
for i=1:len
plot3([x(i), x(i)], [y(i), y(i)], [0, z(i)], 'b--')
end
To draw a line joining each scatter point to the vertical axis use:
for i=1:len
plot3([0, x(i)], [0, y(i)], [z(i), z(i)], 'r--')
end
Final result for len=5 (random points):
  5 Kommentare
Giovanni Mottola
Giovanni Mottola am 6 Okt. 2016
Try:
view([0, 0])
ylim([0 2.2])
xlim([0 2.2])
zlim([0 2.2])
And
view([90, 0])
ylim([0 2.2])
xlim([0 2.2])
zlim([0 2.2])
Joel
Joel am 6 Okt. 2016
Thanks Giovanni!
You are/were indeed right that it is an issue of perspective.
Still if I would like to show this plot to someone it is very misleading. By looking at the figure I posted one does not think the Z value is 2.
I tried some other perspectives and I noticed that when the first variable of view is negative I get plot where it seems like Z is not 2. If I change it to positive, then it looks as I expect it to!
Thank you very much for your help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by