Draw Lines from the origin of a coordinate system to specific points

251 Views Asked by At

I have data that have 3 points to display in a 3D coordinate system. I want a line between each point and the coordinate origin (0 0 0). How can I draw these lines not connecting the points with each other but only with the origin?

I'm not very into gnuplot yet: I'm using the following code to display my data:

splot "C:/a/Drehmatrizenxyz.txt" with lines

But this only connects the points, which is exactly what I do not want.

Thank you.

2

There are 2 best solutions below

0
On

Data file contains six values for each line. From origin is (0 0 0 x y z)

Example - plot vectors <-1,2,-4>, <-2,0,1> & <2,9,2>

file.dat:

0 0 0 -1 2 -4

0 0 0 -2 0 1

0 0 0 2 9 2

gnuplot> splot 'file.dat' with vectors

vectors

0
On

In case this is still of interest... Please check the gnuplot homepage and basic gnuplot tutorials and in gnuplot console help vectors or in general help <keyword>.

Code:

### plot with vectors from origin
reset session

$Data <<EOD
1  2  3
4  5  6
7  8  1
EOD

set view equal xyz
set view 56,48, 1.3
set xyplane relative 0

splot $Data u (0):(0):(0):1:2:3 w vectors 
### end of code

Result:

enter image description here