MathGroup Archive 1992

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

Search the Archive

More Graphics

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: More Graphics
  • From: twj
  • Date: Wed, 16 Sep 92 21:24:37 CDT

This is how graphics output work.

A command like Plot3D or Plot generates a sequence of primitives
and returns a result wrapped in Show.

Show[ graphics] will then evaluate.   
Show does 3 things:

1)	Show adds options to graphics objects
	thus Show[ %, Axes -> False] does its stuff.

2)	Show will combine graphics functions coercing
	them to be of the same type.

3)	Show will extract the value of the option 
	DisplayFunction and return an expression
	with this value as the head.   Thus the result will
	be DisplayFunction[ graphics].  We can
	see what this result is:

In[10]:= Options[ Plot, DisplayFunction]

Out[10]= {DisplayFunction :> $DisplayFunction}

In[11]:= $DisplayFunction

Out[11]= Display[$Display, #1] &


Thus it will return the result Display[ $Display, #]& [ graphics]
which evaluates to Display[ $Display, graphics].   
Display is the lowest level graphics function and renders a graphics
object into PostScript.  

So far there have been no assumptions made about the actual form 
of the graphics output.  

If you want to work with some totally external form of graphics which
is distinct from PostScript and closer to the actual form of the graphics
expression in Mathematica you will want to use your own function for
DisplayFunction.  Maybe you want to keep the actual 3D structure of the
image.  An example is the AVS modules available which set
$DisplayFunction to be a MathLink procedure which exports the 3D
graphics into an AVS link.   This means that commands like Plot3D 
and ParametricPlot3D work in just the normal way.

To make this happen you might do something like

$DisplayFunction = LinkWrite[ MyLink, #]&

which will write the Mathematica expression out over MathLink.



If you actually want to work with PostScript you probably want to use
the Mathematica command Display in conjunction with the default
$DisplayFunction which is set up to send graphics to $Display.
For example you could do something like

$Display = "!psfix  > /tmp/math.ps; gs /tmp/math.ps"

and graphics will be sent via a pipe to psfix which will continue
to do it's stuff.

Even if you want to work with PostScript you may want to make your own
DisplayFunction.  You may want this to be a function which opens a temporary
file writes the PostScript into this file, calls an external process on this
file and deletes the file.  This is what must be done if you don't have pipes
available.


I hope this is useful.

Tom Wickham-Jones
WRI






  • Prev by Date: integration puzzlement
  • Next by Date: Re: Integrating Normal Distributions gives the wrong answer
  • Previous by thread: Re: integration puzzlement
  • Next by thread: Re: acting on a matrix