1
$\begingroup$

I have data for the components of the vectors at multiple points and want to plot something like a vector field from my points which obviously has to be done vector by vector because I do not know the equation of the field that I plot.

Is there a way I can plot the vectors vector by vector in 3D space?

$\endgroup$
2
  • $\begingroup$ Have you seen ListVectorPlot[] and ListVectorPlot3D[]? $\endgroup$ Mar 20, 2018 at 14:47
  • $\begingroup$ Perhaps you are looking for something like this? $\endgroup$
    – Artes
    Mar 20, 2018 at 19:03

1 Answer 1

1
$\begingroup$

Mathematica has a graphics primitive, Arrow, that will do what you ask. You may also need the graphics primitive Arrowheads to adjust the look of the arrowheads if you don't like the default arrowheads.

To demonstrate the use of Arrow, I will generate a set of tangents to function given by

f[x_] := 4 - x^2

vector[tail : {_, _}, slope_, length_: 1.] :=
  Module[{θ = ArcTan[slope]}, {tail, tail + length {Cos[θ], Sin[θ]}}]

tangetVectors = N @ Table[vector[{x, f[x]}, f'[x], .5], {x, Subdivide[-2, 2, 8]}]
{{{-2., 0.}, {-1.87873, 0.485071}}, 
 {{-1.5, 1.75}, {-1.34189, 2.22434}}, 
 {{-1., 3.}, {-0.776393, 3.44721}}, 
 {{-0.5, 3.75}, {-0.146447, 4.10355}}, 
 {{0., 4.}, {0.5, 4.}}, 
 {{0.5, 3.75}, {0.853553, 3.39645}}, 
 {{1., 3.}, {1.22361, 2.55279}}, 
 {{1.5,1.75}, {1.65811, 1.27566}}, 
 {{2., 0.}, {2.12127, -0.485071}}}

Now I will plot the curve 4 - x^2 along with the tangent vectors.

Plot[f[x], {x, -2, 2},
  AspectRatio -> 1,
  PlotStyle -> {Red, Dotted},
  PlotRangePadding -> {{Automatic, .2}, {.5, Automatic}},
  Epilog -> {AbsoluteThickness[1.5], Arrow /@ tangetVectors}]

plot

If you don't want to put the vectors on plot, but only want to show the vectors themselves, use Graphics in place of Plot

Graphics[{AbsoluteThickness[1.75], Arrow /@ tangetVectors}]

graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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