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  /


You can do most standard plots in three dimensions using the built-in functions Plot3D, ListPlot3D and ParametricPlot3D. In certain situations you may want to display your data in a more specialized format, such as a three-dimensional bar chart or a scatter plot. You may also want special effects, such as shadows or projections. In these cases you can use the functions in this package to produce the appropriate plot.

Making three-dimensional bar charts.

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

  • This gives a bar chart made from a two-by-three array of bars with integer height.
  • In[2]:= BarChart3D[{{1, 2, 3}, {4, 5, 6}}]

  • The plot can be redisplayed using any option that can be given for a Graphics3D object. This turns off the simulated lighting model and removes the axes and bounding box.
  • In[3]:= Show[%, Lighting->False,
    Boxed->False, Axes->False]

    Options for BarChart3D.

    BarChart3D has options XSpacing and YSpacing, which determine the amount of spacing between bars in the coordinate directions. This must be a number between and ; the default value is 0. BarChart3D returns a Graphics3D object. This means you can give any option that can be specified for a Graphics3D object. BarChart3D has default option settings Axes

    ->True and BoxRatios->{1,1,1}.

    Plotting lists of points in three dimensions.

    The built-in function ListPlot will take a list of pairs of coordinates and plot them as points in the plane. To plot a list of triples in three dimensions, you can use ScatterPlot3D. ScatterPlot3D will also accept the PlotStyle option to specify a style for the points or curve being displayed. ListSurfacePlot3D uses an array of points to generate the vertices of polyhedra.

  • Here is a list of points in three dimensions.
  • In[4]:= lpts = Table[{ t Cos[t], t Sin[t], t},
    {t, 0, 4Pi, Pi/20}];

  • This produces a scatter plot of the points. They lie on a conical helix.
  • In[5]:= ScatterPlot3D[lpts]

  • This connects the points with a heavy line.
  • In[6]:= ScatterPlot3D[lpts,
    PlotJoined -> True,
    PlotStyle -> Thickness[0.03]]

  • Here is an array of points in three dimensions.
  • In[7]:= apts = Table[{Cos[t] Cos[u], Sin[t] Cos[u],
    Sin[u]}, {t, 0, Pi, Pi/5},
    {u, 0, Pi/2, Pi/10}];

  • The array of points is used to generate vertices in a polygonal mesh. It creates a piece of a sphere.
  • In[8]:= ListSurfacePlot3D[apts]

    Plots with shadows.

    ShadowPlot3D and ListShadowPlot3D work exactly like the built-in Plot3D and ListPlot3D, except shadows are drawn.

  • This puts the shadow in the

  • In[9]:= ShadowPlot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}]

  • Here is another plot with the shadow moved to the top of the bounding box.
  • In[10]:= ShadowPlot3D[ Exp[-(x^2 + y^2)],
    {x, -2, 2}, {y, -2, 2},
    ShadowPosition -> 1]

    Options for ShadowPlot3D and ListShadowPlot3D.

    Shadow has options that determine whether a shadow is drawn in a particular direction. These options are XShadow, YShadow and ZShadow. The default value for all these options is True. The options XShadowPosition, YShadowPosition, and ZShadowPosition determine whether the projection of the shadow is in the positive or negative coordinate direction. Their default value is -1.

  • This generates a three-dimensional graphics object using the built-in ParametricPlot3D.
  • In[11]:= dbell = ParametricPlot3D[
    {Sin[t], Sin[2t] Sin[u], Sin[2t] Cos[u]},
    {t, -Pi/2, Pi/2}, {u, 0, 2Pi},
    Ticks -> None]

  • This shows the graphics objects with projections from the and

  • In[12]:= Shadow[dbell, ZShadow -> False]

  • Here is the same object with the

    shadow moved to the other face of the bounding box.
  • In[13]:= Shadow[dbell, ZShadow -> False,
    XShadowPosition -> 1]

    Projections of three-dimensional graphics objects.

  • This shows the projection of the "dumbbell" onto the plane normal to its center and the vector {1,1,0}.
  • In[14]:= Show[Project[dbell, {1, 1, 0}]]

  • Here is the projection onto another plane.
  • In[15]:= Show[Project[dbell, {0, 1, 0}]]

  • Changing the basis vectors of the projection plane has the effect of rotating it.
  • In[16]:= Show[Project[dbell,
    {{1, 1, 0}, {0, 0, 1}},
    {0, 1, 0}]]

    Stacking graphics.

  • This generates a list of two-dimensional graphics objects. Setting DisplayFunction->Identity stops Plot from rendering the graphics it produces.
  • In[17]:= gtab = Table[
    Plot[x^n, {x, 0, 5},
    DisplayFunction -> Identity], {n, 5}]


  • This shows the graphics "stacked" in a cube.
  • In[18]:= Show[StackGraphics[gtab]]

    Note that ShadowPlot3D, ListShadowPlot3D, and Shadow all produce and display a three-dimen- sional graphics object. On the other hand, Project and StackGraphics only produce the graphics object. To display the object, you must use Show.