Maxima vs Gnuplot vs Mouse



A few months ago, A.G.Grozin@inp.nsk.su asked about the following problem:

When you run gnuplot via plot3d from maxima on a Linux system, the mouse 
  is dead and you can't rotate the graphs.  This is because once the 
main gnuplot process dies, the mouse is dead in the graphics window.  In 
other words, it has nothing to do with maxima.

With a couple of hours of digging, I came up with the following workaround.

I think it's the only way without rewriting gnuplot.  This requires that 
there be an active gnuplot command window that lives until you are done 
with the graph window.  I run that in an xterm.  It's ugly, but it 
works.   When you're done with the plot, just close the gnuplot command 
window.

1.  In my maxima lisp startup file I set gnuplot_command to a shell script.
2.  In my maxima maxima startup file I turn on mouse interaction and set 
pm3d so I get pretty colors.
3.  The shell script runs an xterm.  The xterm runs an expect script.
4.  The expect script tells gnuplot to read the plot file that maxima 
wrote for gnuplot.

.maxima/maxima-init.lisp (maxima lisp startup file):
--------------------------------
(setf $gnuplot_command "doplot")
--------------------------------


.maxima/maxima-init.mac (maxima maxima startup file):
-------------------------------------------------
set_plot_option([gnuplot_preamble, "set mouse"]);
set_plot_option([gnuplot_pm3d, true]);
-------------------------------------------------

doplot.expect  (expect script to run gnuplot and tell it to load the 
plot file):
--------------------------------
#!/usr/bin/expect

spawn gnuplot
send "load \"maxout.gnuplot\"\r"
interact
--------------------------------

doplot  (shell script to run the expect script in the background)
------------------------
xterm -e doplot.expect &
------------------------


-- 
Fred Sullivan
Associate Professor of Computer Science
Wilkes University                        sullivan@mathcs.wilkes.edu
Wilkes-Barre, PA  18766                              (570) 408-4727

First you make a roux!