This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Add-ons / Standard Packages / Graphics  /


This package allows the graphical display of vector fields in three dimensions. The vector field can be represented by lines or arrows which can display direction and magnitude.

Plotting vector fields in three dimensions.

  • This loads the package.
  • In[1]:= <<Graphics`PlotField3D`

  • The components of this vector field are given by , , and

  • In[2]:= PlotVectorField3D[{y , -x, 0}/z ,
    {x, -1, 1}, {y, -1, 1}, {z, 1, 3}]

    The gradient of a scalar function is the vector field with components given by , , and , respectively. PlotGradientField computes formulas for the partial derivatives and generates a vector field plot. Thus the function must be such that Mathematica

    can compute its derivatives.

  • Here is the gradient field of the scalar function

  • In[3]:= PlotGradientField3D[
    x y z, {x, -1, 1}, {y, -1, 1}, {z,-1,1}]

    Options for vector field plotting.

  • This sets the number of sample points in each direction to

    and puts heads on the arrows.
  • In[4]:= PlotVectorField3D[{x , y, z}, {x, 0, 2},
    {y, 0, 2}, {z, 0, 2}, PlotPoints -> 5,
    VectorHeads -> True]

    A variable range specification of the form

    x,xmin,xmax,dx adjusts the evaluation grid by specifying step sizes of dx in the direction. An analogous specification in the and ranges will adjust the evaluation grid in those directions. You can also adjust the evaluation grid by setting the PlotPoints


    Vector field plots from lists.

  • This gives an array of random vectors.
  • In[5]:= array = Flatten[
    Table[ {{i, j, k},
    {Random[Real, {-1, 1}],
    Random[Real, {-1, 1}],
    Random[Real, {-1, 1}]}},
    {i, 7}, {j, 7}, {k, 7}], 2];

  • This displays the vectors.
  • In[6]:= ListPlotVectorField3D[array]

    It is often hard to arrange the number of points to have enough samples without making the image overly complex. One way to overcome this is to construct an animation that rotates the whole image.