MathGroup Archive 1995

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

Search the Archive

Re: Mathlink & Graphics....

  • Subject: [mg2228] Re: Mathlink & Graphics....
  • From: wagner at (Dave Wagner)
  • Date: Tue, 17 Oct 1995 06:34:56 GMT
  • Approved:
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: University of Colorado, Boulder
  • Sender: daemon at ( )

In article <45d1sc$63m at>,
The GodFather <gandalf at> wrote:
>	Unix Platform....
>	I've been trying to do this for a bit of time....
>	Basically, I would like from a C-code, to generate
>	a list of numbers {{1,2},{2,1}} and plot their positions
>	using mathematica's handy plotting routines....
>	If someone could post a way to simply execute a 
>	Plot[x^2,{x,-2,2}], and either have mathematica display
>	it (in X), or return PostScript to the link stream or
>	to an output file I would be extremely grateful....
>	An example of the type of thing I'm trying to do....
>	from within C-code:
>	MLPutFunction(link,"Extend",1); 
>	PutString(link,"Plot[x^2,{x,-2,2});
>	If there was some way of setting the DisplayFunction
>	so mathematica would then just plot this thing out 'twould
>	be beautiful.  If there was some way I could get it to
>	output the plot to a postscript file, I would be joyous.
>	If there was any way I could get useable output, basically
>	I would be dancing around for weeks....
>	with much appreciation,
>	-John Joseph

You can redirect the PostScript output of a plotting command by overriding
DisplayFunction.  The default setting for DisplayFunction is $DisplayFunction,
which is


This function is applied to the Graphics object that is generated by
the plot command.  Display is a built-in function that sends graphics
to a particular place:


    Display[channel, graphics] writes graphics or sound to the
    specified output channel.

The default value for $Display is:


so, you can accomplish what you want to do by (a) opening a stream to
a file in Mathematica, (b) one of the following:

	- set $Display to that stream
	- set $DisplayFunction to Display[stream, #]&
	- use the option DisplayFunction:>Display[stream, #]& in
	  your plotting command.  This is probably the best option
	  since you'll undoubtedly want to use a different stream
	  for each plot.

Note that the contents of the file with be Mathematica-ese PostScript,
which isn't interpretable by most PostScript interpreters, I don't think.
There's a UNIX program that can do it that's distributed on MathSource,
I believe.

Let me know if this makes you dance...

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at

  • Prev by Date: Re: Constructing Expressions from List Elements
  • Next by Date: Mma & ANOVA : package for calculating sums of squares????
  • Previous by thread: RE: Mathlink & Graphics....
  • Next by thread: RE: Mathlink & Graphics....