MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Epilog -vs- Prolog -vs- DisplayTogether

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58102] Re: [mg58048] Epilog -vs- Prolog -vs- DisplayTogether
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 18 Jun 2005 06:07:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

The Mathematica graphics paradigm is built around a collection of what I
call set-piece plots. A set-piece plot is a plot of a particular kind and
style. Almost all of the plot statements in Mathematica are set-piece plots:
Plot, ImplicitPlot, FilledPlot, Plot3D, ParametricPlot3D, ContourPlot, et
cetera. They are easy to use and impressive - PROVIDED that is the kind of
graphics you want.

If you want to customize a graphic, or produce a graphic that involves
multiple plot types, then things begin to get unintuitive and complicated -
as is easily seen by the many questions relating to graphics posted on
MathGroup.

Options are the first method for customizing plots. But these are sometimes
confusing. There are basically two kinds of options, those that affect the
production of the actual curve, surface or plotted item, such as PlotPoints
or PlotStyle, and those that affect the overall plot style such as Frame,
Axes, Ticks, ImageSize, et cetera.

Next there is the problem of combining items produced by various types of
plots, or combining a curve or surface with graphics primitives such as
Text. This is where Prolog, Epilog, Show and DisplayTogether come in. They
are all, in my opinion, confusing and inadequate methods. You might want to
set some graphics directives before you draw a curve, say. You could use
Prolog -> {Red, AbsoluteThickness[2]}. Then these would be in effect when
the curve was drawn. Or in a ListPlot you could use Prolog ->
{AbsolutePointSize[5]} to make the points larger. Of course, you could also
do these things with the PlotStyle option. You could use Epilog to add Text
and other graphics primitives to a plot. If you want to combine a curve with
Text and a number of Circles, Rectangles, Lines and Polygons, then the
Epilog option will become the tail that wags the dog. If you want to include
several curve types then you need DisplayTogether or Show. DisplayTogether
is a command to combine various plots together but it has its gotchas. If,
for example, you had several curve plots containing Epilog statements to add
Text to the curves, then DisplayTogether will only pick up ONE of the Epilog
options - the first one. So, using that method you would have to add the
Text for the second plot to the Epilog statement for the first plot. Or you
could leave out all the Text statements in the initial plots and add them
all at once in an Epilog statement in a Show statement.

All of this is very confusing to beginners and even to some advanced users
of Mathematica. There are work arounds and solutions for doing various
things, but they are not obvious to most users. The result is that many
users do not get as much from Mathematica graphics as they deserve.

The trouble with the set-piece paradigm is that it is on a different level
than the graphics primitives and graphics directives. To mix curves or
surfaces with primitives you have to keep shifting levels or know how to dig
into graphics output to get the primitives. There is also the annoyance of
having extra side plots or having to go to the trouble of suppressing them.
The first principle of Mathematica is 'Everything is an Expression'. The
first principle of Mathematica graphics SHOULD be 'Everything is a Graphics
Primitive'. That is the problem. When using set-piece plots to draw curves
and surfaces Mathematica does not DIRECTLY represent these items as graphics
primitives.

The natural way to generate graphics on a piece of paper is to select a
pencil of the size and color you want and then draw the curve. Then select
another pencil or brush and another color and draw some other curve or item.
Pencil in text at suitable points. Continue until you complete your graphic.

That's why I put together the DrawGraphics package, available at my web
site. There, each of the set-piece plots is converted to a corresponding
Draw statement that extracts the graphics primitives (without side display
of the plot). Draw extracts the graphics primitives from Plot,
ParametricDraw from ParametricPlot, ImplicitDraw from ImplicitPlot, et
cetera. Then you can simply draw various items, one after the other, in a
single graphics statement. The overall plot style options are put at the end
of the single statement, and the options that affect each generated item are
put in the corresponding Draw statements. It is the natural, intuitive way
of doing things.

Here is a fanciful piece of graphics that combines a ContourPlot, a Disk, a
Circle, a DensityPlot, a regular Plot, a ParametricPlot, an ImplicitPlot,
the points generated by Mathematica for the ImplicitPlot, some Text and
various graphics directives.

Needs["DrawGraphics`DrawingMaster`"]

Draw2D[
{ContourDraw[Sin[x*y], {x, -Pi/2, Pi/2}, {y, -1, 1}],
 Orchid,
 Disk[{0, 0}, Sqrt[2]/4],
 Black,
 Circle[{0, 0}, Sqrt[2]/4],
 DensityDraw[Sin[x*y], {x, -4^(-1), 1/4}, {y, -4^(-1), 1/4},
ColorFunction -> Hue,
     PlotPoints -> 8],
 Peacock,
 Draw[Sin[x], {x, -Pi/2, Pi/2}],
 Red,
 ParametricDraw[{Cos[t], Sin[t]}, {t, 0, 2*Pi}],
 Blue,
 ellipse = ImplicitDraw[x^2 + 3*y^2 == 1, {x, -1, 1}],
 LightBlue, PointSize[0.01],
 ellipse /. Line[pts_] :> Point /@ pts,
 Gold,
 Text["DrawGraphics!",
     Scaled[{0.95, 0.1}], {1, -1}]},

 Frame -> True,
 AspectRatio -> Automatic,
 Background -> Linen,
 ImageSize -> 500,
 TextStyle -> {FontSize -> 12, FontWeight -> "Bold"},
 PlotLabel -> "Combining Plots, Graphics Primitives\n\t and Graphics
Directives"];
Clear[ellipse]

No Prolog. No Epilog. No side plots. No DisplayTogether. Just draw the items
one after another.

Many users are waiting for a new 'Graphics Version' of Mathematica. I wonder
what they will do? Change the paradigm or add more set-piece plots, bells
and whistles. From the way they fragmented Colors in Version 5.1 and broke
their own code I will keep my hopes modest.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/






From: nafod40 [mailto:noneya at business.com]
To: mathgroup at smc.vnet.net


Subject says it all. It is not clear to me the benefits of Epilog and
Prolog over DisplayTogether, or when I'd use Epilog versus Prolog or
vice versa. Mathematica book is kind of lean in that area. Anyone want to
offer
up some suggestions? What motivated their implementation in the first place?




  • Prev by Date: Re: Re: usage messages in packages
  • Next by Date: Re: For Loop and Array related
  • Previous by thread: Re: Epilog -vs- Prolog -vs- DisplayTogether
  • Next by thread: Re: Re: Epilog -vs- Prolog -vs- DisplayTogether