Epilog, Prolog

Epilog and Prolog are options for Graphics functions which give are used to give a list of graphics primative (Circle, Line, Point, ...) to be rendered before or after the main part of the graph.  The Prolog  graphics are rendered before the main part of the graphics.  The Epilog graphics are rendered after the main part of the graphics.

The cell below shows red points drawn before the line using Prolog.  Also shown are red points drawn after the lines using Epilog.

data1 = Table[{x, x}, {x, 0, 6}] ;    RowBox[{RowBox[{Block, [, RowBox[{{$DisplayFunction  ...   , ]}],   }] Show[GraphicsArray[{PointsFirst, PointsLast}], ImageSize-> {400, 100}] ;

The next example was inspired by a problem Jurgen Tisher answered in the MathGroup.  You should be wary of using  Epilog and Prolog for applications where you may combine the results with other graphics at a later time using Show.  The reason for this is demonstrated in this example.

data1 = Table[{x, x}, {x, 0, 6}] ; data2 = Table[{x, x + 2}, {x, 0, 6}] ;    RowBox[{RowBo ... ], ]}]}], ;}]}],   , ]}],   }] Show[GraphicsArray[{p1, p2}], ImageSize-> {400, 100}] ;

In the GraphicsArray above the Points made with Epilog are shown in the plots for p1 and p2.  When the two graphics below are combined only the Epilog graphics for p1 are shown.

Show[p1, p2] ;

The Epilog graphics for p2 were not displayed because Show concatenates together the options for each graphic.  As a result only the first Epilog options and the first Prolog option is used.  By using FullGraphics the graphics for p1 and p2 can be converted to graphic primitives, and all the intended graphics are displayed.  However, this demonstration is misleading because the manual settings used for PlotRange above were carefully selected to ensure the result below comes out looking good.  If you make p1 and p2 using the PlotRange→Automatic the graphic below doesn't come out as nice.  

It turns out that Prolog has the same weakness.

Show[FullGraphics[p1], FullGraphics[p2]] ;


Created by Mathematica  (May 16, 2004)

Back to Ted’s Tricks index page