Converting Maple code into LaTeX markupMaple and LaTeXIncluding Maple graphics in LaTeX documents

Including Maple graphics in LaTeX documents

Since it is straightforward to include graphics in PostScript format in a LaTeX document, it is useful to know how to convert Maple plots into PostScript. The most flexible method uses the Maple "plotsetup" command.

For example, open up Maple and execute the command

     plot3d((1.3)^x*sin(y), x=-1..2*Pi, y=0..Pi, 
                 coords=spherical, style=patch);

which should display a cornucopia. To create a PostScript file of this graph, execute the Maple command

     plotsetup(postscript, plotoutput=`cornucopia.ps`, 
         plotoptions=`color,portrait,height=300,width=300`);

and then execute the plot3d command again. Now instead of displaying the graph on the screen, Maple will write out to disk a PostScript version of the graph. To view the PostScript file, execute the command ghostview cornucopia.ps & at the command prompt in a terminal window.

Note that the plotsetup command affects the whole Maple session. If you want to save several plots, you need to issue several plotsetup commands with different values specified for plotoutput. To make Maple revert to displaying plots on the screen, issue the command plotsetup(default);.

If you simply say "plotsetup(postscript);" without specifying a value for plotoptions, then Maple will by default create a monochrome image, in landscape orientation, scaled to fill a whole page, and with a border. You can add "noborder" to the list of plotoptions to eliminate the border. The numbers specified for the height and width of the image have units of PostScript points. (There are 72 PostScript points in an inch.) However, the height and width include margins of one-half inch on all sides of the image.

An alternative way to make a PostScript file of a Maple graph is to display the graph in its own window (either set the Plot Display on the Options menu to Window, or issue the Maple command plotsetup(x11);) and then select Print from the File menu. However, this alternate method gives you less flexibility for setting options. Of course, you can always rescale images inside LaTeX with the \resizebox command.

If you want to include a Maple plot in a World-Wide Web page, you can replace "postscript" in the "plotsetup" command with "jpeg" to create a JPEG image or with "gif" to create a GIF image. Alternatively, you can convert an entire Maple worksheet into an HTML document by using the Export As HTML feature on Maple's drop-down File menu.

Of course, if you wish to ignore the Maple plotsetup command, then you can simply grab graphics off the screen with a graphics program like xv. The disadvantage of this method is that modifying your work in the future becomes harder.

Exercise on "Farris wheels"

The mathematics in this exercise comes from the following article:

Frank A. Farris
Wheels on Wheels on Wheels--Surprising Symmetry
Mathematics Magazine 69 (1996), number 3, 185-189.

There is an interesting follow-up article:

Frank A. Farris and Nils Kristian Rossing
Woven Rope Friezes
Mathematics Magazine 72 (1999), number 1, 32-38;
associated web site.

Start by examining the plot generated by the following Maple commands.

x := t -> cos(t) + cos(7*t)/2 + sin(17*t)/3;
y := t -> sin(t) + sin(7*t)/2 + cos(17*t)/3;
plot([x(t), y(t), t=0..2*Pi],axes=none,thickness=3,color=green);

Farris
wheel Your plot should look something like the figure. Notice that the plot has six-fold symmetry. Figure out why you should be able to tell ahead of time from the equations that this symmetry is present. (Hint: the numbers 7 and -17 are both congruent to 1 modulo 6.)

The physical interpretation is that the curve represents the position of a particle on a wheel whose center is mounted on the rim of a second wheel whose center is mounted on the rim of a third wheel, each wheel turning at a different rate.

Do you remember Euler's formula about complex exponentials? It says that eit = cos(t) + i sin(t). You can get the same plot using complex exponential notation as follows.

z := t -> exp(I*t) + exp(7*I*t)/2 + I*exp(-17*I*t)/3;
plot([Re(z(t)), Im(z(t)), t=0..2*Pi], 
        axes=none, thickness=3, color=green);

Next try plotting the curve given in exponential notation by z(t) = e-2it + (1/2)e5it + (1/4)e19it. How can you tell from the equation that the plot has 7-fold symmetry?

Write a LaTeX document explaining the symmetry of such figures and displaying some pretty plots of your own devising. (For example, can you find an attractive plot with 9-fold symmetry?) Be sure to identify the function that generates each figure you include in your paper.


logo The Math 696 course pages were last modified April 5, 2005.
These pages are copyright © 1995-2005 by Harold P. Boas. All rights reserved.
 
Converting Maple code into LaTeX markupMaple and LaTeXIncluding Maple graphics in LaTeX documents