This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

The Structure of Graphics

"Graphics and Sound" discusses how to use functions like Plot and ListPlot to plot graphs of functions and data. This tutorial discusses how Mathematica represents such graphics, and how you can program Mathematica to create more complicated images.
The basic idea is that Mathematica represents all graphics in terms of a collection of graphics primitives. The primitives are objects like Point, Line, and Polygon, which represent elements of a graphical image, as well as directives such as RGBColor and Thickness.
This generates a plot of a list of points.
Click for copyable input
InputForm shows how Mathematica represents the graphics. Each point is represented as a coordinate in a Point graphics primitive. All the various graphics options used in this case are also given.
Click for copyable input
Each complete piece of graphics in Mathematica is represented as a graphics object. There are several different kinds of graphics object, corresponding to different types of graphics. Each kind of graphics object has a definite head that identifies its type.
Graphics[list]general two-dimensional graphics
Graphics3D[list]general three-dimensional graphics

Graphics objects in Mathematica.

The functions like Plot and ListPlot discussed in "The Structure of Graphics and Sound" all work by building up Mathematica graphics objects and then displaying them.
You can create other kinds of graphical images in Mathematica by building up your own graphics objects. Since graphics objects in Mathematica are just symbolic expressions, you can use all the standard Mathematica functions to manipulate them.
Graphics objects are automatically formatted by the Mathematica front end as graphics upon output. Graphics may also be printed as a side effect using the Print command.
The Graphics object is computed by Mathematica, but its output is suppressed by the semicolon.
Click for copyable input
A side effect output can be generated using the Print command. It has no Out label because it is a side effect.
Click for copyable input
Show[g,opts]display a graphics object with new options specified by opts
Show[g1,g2,...]display several graphics objects combined using the options from
Show[g1,g2,...,opts]display several graphics objects with new options specified by opts

Displaying graphics objects.

Show can be used to change the options of an existing graphic or to combine multiple graphics.
This uses Show to adjust the Background option of an existing graphic.
Click for copyable input
This uses Show to combine two graphics. The values used for PlotRange and other options are based upon those which were set for the first graphic.
Click for copyable input
Here, new options are specified for the entire graphic.
Click for copyable input
Graphics directivesExamples: RGBColor, Thickness
Graphics optionsExamples: PlotRange, Ticks, AspectRatio, ViewPoint

Local and global ways to modify graphics.

Given a particular list of graphics primitives, Mathematica provides two basic mechanisms for modifying the final form of graphics you get. First, you can insert into the list of graphics primitives certain graphics directives, such as RGBColor, which modify the subsequent graphical elements in the list. In this way, you can specify how a particular set of graphical elements should be rendered.
This creates a two-dimensional graphics object that contains the Polygon graphics primitive.
Click for copyable input
InputForm shows the complete graphics object.
Click for copyable input
This takes the graphics primitive created above and adds the graphics directives RGBColor and EdgeForm.
Click for copyable input
By inserting graphics directives, you can specify how particular graphical elements should be rendered. Often, however, you want to make global modifications to the way a whole graphics object is rendered. You can do this using graphics options.
By adding the graphics option Frame you can modify the overall appearance of the graphics.
Click for copyable input
InputForm shows that the option was introduced into the resulting Graphics object.
Click for copyable input
You can specify graphics options in Show. As a result, it is straightforward to take a single graphics object and show it with many different choices of graphics options.
Notice however that Show always returns the graphics objects it has displayed. If you specify graphics options in Show, then these options are automatically inserted into the graphics objects that Show returns. As a result, if you call Show again on the same objects, the same graphics options will be used, unless you explicitly specify other ones. Note that in all cases new options you specify will overwrite ones already there.
Options[g]give a list of all graphics options for a graphics object
Options[g,opt]give the setting for a particular option

Finding the options for a graphics object.

Some graphics options can be used as options to visualization functions that generate graphics. Options which can take the right-hand side of Automatic are sometimes resolved into specific values by the visualization functions.
Here is a plot.
Click for copyable input
Mathematica uses an internal algorithm to compute an explicit value for PlotRange in the resulting graphic.
Click for copyable input
FullGraphics[g]translate objects specified by graphics options into lists of explicit graphics primitives

Finding the complete form of a piece of graphics.

When you use a graphics option such as Axes, the Mathematica front end automatically draws objects such as axes that you have requested. The objects are represented merely by the option values rather than by a specific list of graphics primitives. Sometimes, however, you may find it useful to represent these objects as the equivalent list of graphics primitives. The function FullGraphics gives the complete list of graphics primitives needed to generate a particular plot, without any options being used.
This plots a list of values.
Click for copyable input
FullGraphics yields a graphics object that includes graphics primitives representing axes and so on.
Click for copyable input