Re: Displaying graphics with the MathKernel in OS X
- To: mathgroup at smc.vnet.net
- Subject: [mg82939] Re: Displaying graphics with the MathKernel in OS X
- From: mcmcclur at unca.edu
- Date: Sun, 4 Nov 2007 06:07:33 -0500 (EST)
- References: <fgenq7$g2d$1@smc.vnet.net>
On Nov 2, 4:40 am, kevin_jazz <kevinbow... at mac.com> wrote:
> I'd like to use Mathematica the "old fashion" way by using
> the MathKernel with the notebook. However, I'd like to be
> able to display graphics.
I think this is exactly the the point behind JavaGraphics.
The following terminal session opens a window in a small
Java application and displays the results.
-------------- Begin Mathematica session -----------------
Mathematica 6.0 for Mac OS X x86 (32-bit)
Copyright 1988-2007 Wolfram Research, Inc.
In[1]:= <<JavaGraphics`
-- Java graphics initialized --
In[2]:= Plot[Sin[x]/x, {x,-2*Pi,2*Pi}, ImageSize -> 800];
-------------- End Mathematica session -------------------
You can also write your own display function that calls
an external program. I suppose a logical external viewer
on Mac OS X is Preview. Here's one way to set this up.
-------------- Begin Mathematica session -----------------
Mathematica 6.0 for Mac OS X x86 (32-bit)
Copyright 1988-2007 Wolfram Research, Inc.
In[1]:= Developer`InstallFrontEnd[];
In[2]:= df[g_] := Module[
{strm},
strm = OpenWrite["!open -f -a /Applications/Preview.app"];
WriteString[strm, ExportString[g, "EPS"]];
Close[strm];
];
In[3]:= $DisplayFunction = df;
In[4]:= Plot[x^2, {x,-2,2}]
-------------- End Mathematica session -------------------
Note that many commands involving Import/Export will
start up a FrontEnd in the background; the first
version using JavaGraphics does this, for example,
as you can see using top. For some reason, this
second version hangs without an explicit installation
of a FrontEnd.
Mark