This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

Labeling Three-Dimensional GraphicsFormats for Text in Graphics

2.9.14 Advanced Topic: Low-Level Graphics Rendering

All Mathematica graphics functions such as Show and Plot have an option DisplayFunction, which specifies how the Mathematica graphics objects they produce should actually be displayed. The way this works is that the setting you give for DisplayFunction is automatically applied to each graphics object that is produced.

Settings for the DisplayFunction option.

Within the Mathematica kernel, graphics are always represented by graphics objects involving graphics primitives. When you actually render graphics, however, they must be converted to a lower-level form which can be processed by a Mathematica front end, such as a notebook interface, or by other external programs.

The standard low-level form that Mathematica uses for graphics is PostScript. The Mathematica function Display takes any Mathematica graphics object, and converts it into a block of PostScript code. It can then send this code to a file, an external program, or in general any output stream.

Converting Mathematica graphics to PostScript.

The default value of the global variable $DisplayFunction is Function[ Display[$Display, #] ]. With this default, graphics objects produced by functions like Show and Plot are automatically converted to PostScript, and sent to whatever stream is specified by the value of the global variable $Display. The variable $Display is typically set during the initialization of a particular Mathematica session.

Inserting verbatim PostScript code.

With the standard two-dimensional graphics primitives in Mathematica you can produce most of the effects that can be obtained with PostScript. Sometimes, however, you may find it necessary to give PostScript code directly. You can do this using the special two-dimensional graphics primitive PostScript.

The strings you specify in the PostScript primitive will be inserted verbatim into the final PostScript code generated by Display. You should use the PostScript primitive with care. For example, it is crucial that the code you give restores the PostScript stack to exactly its original state when it is finished. In addition, to specify positions of objects, you will have to understand the coordinate scaling that Mathematica does in its PostScript output. Finally, any PostScript primitives that you insert can only work if they are supported in the final PostScript interpreter that you use to display your graphics.

The PostScript primitive gives raw PostScript code which draws a Bézier curve.

In[1]:= Show[Graphics[ {

PostScript[".008 setlinewidth"],

PostScript[".1 .1 moveto"],

PostScript["1.1 .6 -.1 .6 .9 .1 curveto stroke"] },

Frame -> True]]


In most cases, a particular Mathematica graphics object always generates PostScript of a particular form. For Graphics3D objects, the option RenderAll allows you to choose between two different forms.

The main issue is how the polygons which make up three-dimensional objects should be rendered. With the default setting RenderAll -> True, all polygons you specify are drawn in full, but those behind are drawn first. When all the polygons are drawn, only those in front are visible. However, while an object is being drawn on a display, you can typically see the polygons inside it.

The problem with this approach is that for an object with many layers, you may generate a large amount of spurious PostScript code associated with polygons that are not visible in the final image. You can potentially avoid this by setting RenderAll -> False. In this case, Mathematica works out exactly which polygons or parts of polygons will actually be visible in your final image, and renders only these. So long as there are fairly few intersections between polygons, this approach will typically yield less PostScript code, though it may be much slower.

An option for rendering three-dimensional pictures.

When you generate a PostScript representation of a three-dimensional object, you lose all information about the depths of the parts of the object. Sometimes, you may want to send to external programs a representation which includes depth information. Often, the original Graphics3D object in Mathematica form is then the appropriate representation. But some external programs cannot handle intersecting polygons. To deal with this, Graphics3D includes the option PolygonIntersections. If you set PolygonIntersections -> False, then Show will return not your original Graphics3D object, but rather one in which intersecting polygons have been broken into disjoint pieces, at least with the setting for ViewPoint and so on that you have given.

Labeling Three-Dimensional GraphicsFormats for Text in Graphics