next up previous index
Next: When to Stay Away Up: The Playsome Threesome: Maxima, Previous: Becoming Familiar with Maxima,

   
Simple Plots

Maxima (but not punimax!)  can use 3 different graphics engines for plots. If you run Maxima from

/afs/ovpit.indiana.edu/sun4x_56/gnu/bin
you can use PostScript  and Gnuplot  engines. In order to use Gnuplot issue the command: 
plot3d(sin(x*y), [x,-2,2], [y,-1,1], ['plot_format,gnuplot]); gives 
set parametric

set data style lines

set hidden

splot 'maxout.gnuplot'

save 'gnu-optionsxx'

exit

                                       0
This command produces two windows: one is a Gnuplot window (cf. Figure 2.1), which displays a graph. The other one is a wish, window, which lets you manipulate the graph in the Gnuplot window interactively, so that you can look at it from various directions.2.2


  
Figure 2.1: Surface plot produced by a combination of Maxima and Gnuplot
\includegraphics[width=10cm]{maxout.eps}

Calling plot3d defines a graphics environment for Maxima. You can view it after the call to plot3d simply  by typing:

plot_options; evaluates to 
     [[X, - 3, 3], [Y, - 3, 3], [GRID, 30, 30], [VIEW_DIRECTION, 1, 1, 1], 

[COLOUR_Z, FALSE], [TRANSFORM_XY, FALSE], [RUN_VIEWER, TRUE], 

[PLOT_FORMAT, GNUPLOT], [NTICKS, 100]]

You can also change an option with the command such as:

set_plot_option([plot_format,ps]); evaluates to 
      [[X, - 3, 3], [Y, - 3, 3], [GRID, 30, 30], [VIEW_DIRECTION, 1, 1, 1], 

[COLOUR_Z, FALSE], [TRANSFORM_XY, FALSE], [RUN_VIEWER, TRUE], 

[PLOT_FORMAT, PS], [NTICKS, 100]]
Calling plot3d this time, brings a ghostview window, and you get the following message:
plot3d(sin(x*y), [x, -2, 2], [y, -1, 1]); yields 0
But the resulted PostScript is not encapsulated.

Maxima in

/afs/ovpit.indiana.edu/sgi_63/gnu/bin
is punimax , based on a somewhat older version of Maxima. Sadly, there is something wrong with graphics in that version, so none of the stuff that I have talked above will work if you try to run Maxima on the Ships cluster.

The corresponding surface plotting command in Maple is

plot3d(sin(x*y), x=-2..2, y=-1..1);
In its command line mode Maple will produce character based graphics in your xterm, even if you have DISPLAY declared in your environment. You can change this by issuing the command:
plotsetup(x11);
Calling plotsetup with an empty argument  list returns a list of all plot options currently in force:
> plotsetup();
preplot = [], postplot = [], plotdevice = x11, plotoutput = terminal,

    plotoptions =

>
Once you get a Maple graphic on the screen, it will come up in a separate window, you can rotate it as follows. First click on the figure with your left mouse button. The figure will be replaced with a drawing of a frame. While holding the left button down, drag the mouse to rotate the frame. Then click on the middle mouse button, to fill the frame again with the figure in a new position. The right mouse button brings up a magnifying glass. There are various other menus in the plot window, which you can use in order to change the perspective, colouring, axes, etc. The final result can be saved as a PostScript, GIF, PIC, or a UNIX plot file, and, in this case it should look as shown in Figure 2.2.2.3


  
Figure 2.2: A surface plot produced by Maple
\includegraphics[angle=-90, origin=c, width=7cm]{maple.eps}

Mathematica knows from the beginning if you are working with X11 windows. A command

Plot3D[Sin[x y], {x, -2, 2}, {y, -1, 1}]
brings an X11 -SurfaceGraphics- window on your X11 display. Mathematica graphics are static, i.e., you can't rotate interactively the figure you get. There is a File -> Save As menu choice in the X11 graphics window that saves the plot in an incomplete PostScript  format, which Mathematica alone can read and process without difficulties. In order to print that file or view it with, e.g., Ghostview, you have to run it through a Mathematica   auxiliary utility, psrender, which on the Ships cluster lives in
/usr/local/math301/SystemFiles/Graphics/Binaries/SGI
In order to produce an encapsulated PostScript file shown in Figure 2.3, I've run:
/usr/local/math301/SystemFiles/Graphics/Binaries/SGI/psrender \
   -format eps \
   -pspath \
      /usr/local/math301/SystemFiles/Graphics/SystemResources \
    math.ps > math.eps

But you can also instruct Mathematica  to write an encapsulated PostScript file containing the plot, by using function Display:

In[5]:= Display["math.eps", %, "EPS"]

Out[5]= -SurfaceGraphics-

In[6]:=
Here the percent mark, %, means the same as it in Apple HyperTalk, i.e., the last thing returned by Mathematica. In this case, it's the plot.

The variable $DisplayFunction contains information about the current display settings:

In[6]:= $DisplayFunction

Out[6]= Module[{System`Private`file = OpenTemporary[]}, 
 
>     Display[{$Display, System`Private`file}, #1]; 
 
>      System`Private`file = Close[System`Private`file]; 
 
>      System`Private`$DisplayLinkCommands[System`Private`file, 
 
>       $DisplayTitle]; #1] & 

In[7]:=


  
Figure 2.3: A surface plot produced by Mathematica
\includegraphics[width=10cm]{math.eps}


next up previous index
Next: When to Stay Away Up: The Playsome Threesome: Maxima, Previous: Becoming Familiar with Maxima,
Zdzislaw Meglicki
2001-02-26