# 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 the Wolfram Language represents such graphics, and how you can program the Wolfram Language to create more complicated images.

The basic idea is that the Wolfram Language 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.

In[1]:= |

Out[1]= |

Each complete piece of graphics in the Wolfram Language 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 the Wolfram Language.

The functions like Plot and ListPlot discussed in "The Structure of Graphics and Sound" all work by building up Wolfram Language graphics objects and then displaying them.

You can create other kinds of graphical images in the Wolfram Language by building up your own graphics objects. Since graphics objects in the Wolfram Language are just symbolic expressions, you can use all the standard Wolfram Language functions to manipulate them.

Graphics objects are automatically formatted by the Wolfram System front end as graphics upon output. Graphics may also be printed as a side effect using the Print command.

In[3]:= |

Out[3]= |

Show[g,opts] | display a graphics object with new options specified by opts |

Show[g_{1},g_{2},…] | display several graphics objects combined using the options from |

Show[g_{1},g_{2},…,opts] | display several graphics objects with new options specified by opts |

Show can be used to change the options of an existing graphic or to combine multiple graphics.

In[5]:= |

Out[5]= |

In[6]:= |

Out[6]= |

In[7]:= |

Out[7]= |

Graphics directives | Examples: RGBColor, Thickness |

Graphics options | Examples: PlotRange, Ticks, AspectRatio, ViewPoint |

Local and global ways to modify graphics.

Given a particular list of graphics primitives, the Wolfram Language 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.

In[8]:= |

Out[8]= |

In[10]:= |

Out[10]= |

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*.

In[11]:= |

Out[11]= |

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.

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

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 Wolfram System 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.

In[15]:= |

Out[15]= |

In[16]:= |

Out[16]//Short= | |