24
$\begingroup$

I have an array of data with 3D elements. Ex: x = {{1,2,3}, {3,4,5}, {5,6,7}}. I want to show this data in 3 dimensions, such that each point in the space is shown as a vector originating from the origin. There should be an arrow/line whose one end is at the origin $(0,0,0)$ and the other end at the point $(1,2,3)$.

Which function should I use?

$\endgroup$
1
  • 1
    $\begingroup$ Very well explained. Welcome to Mathematica.SE! $\endgroup$
    – Szabolcs
    Commented Apr 27, 2012 at 9:48

3 Answers 3

24
$\begingroup$

For your problem, it is probably easiest to build the graphic out of graphics primitives rather than use a pre-made convenience function such as ListPointPlot3D.

This is one way to do it:

data = {{1, 2, 3}, {3, 4, 5}, {5, 6, 7}};

Graphics3D[Arrow[{{0, 0, 0}, #}] & /@ data]

Mathematica graphics

I simply used the Arrow graphics primitive. I constructed a pure function that makes an arrow starting from the origin, and mapped it over the data.

$\endgroup$
1
  • $\begingroup$ Do you know how to show the grid inside the box? $\endgroup$
    – London guy
    Commented Apr 27, 2012 at 18:12
10
$\begingroup$

I wasn't able to find a way to make ListPointPlot3D draw lines instead of points.

As an alternative to Szabolcs' Graphics3D, here is a slightly different way using ParametricPlot3D and a replacement rule.

data = {{1, 2, 3}, {3, 4, 5}, {5, 6, 7}};
ParametricPlot3D[data*u, {u, 0, 1}] /. Line -> Arrow

enter image description here

$\endgroup$
0
$\begingroup$

There are many good answers to this problem. Another is to use Arrow function:

Graphics3D[Arrow[{{0, 0, 0}, {2, 3, 4}}]], Axes -> True, 
 AxesLabel -> {x, y, z}]
$\endgroup$
1
  • 1
    $\begingroup$ This is the same what the accepted answer suggests. $\endgroup$
    – Kuba
    Commented Aug 5, 2017 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.