2. Extensions to maxima
wxMaxima aims to be but a graphical user interface for maxima. In some
cases it adds functionality to Maxima, though. These cases are
described here.
2.1 Plotting
Plotting (having fundamentally to do with graphics) is a place where a
graphical user interface will have to provide some extensions to the
original program.
2.1.1 Embedding a plot into the work sheet
Maxima normally instructs the external program gnuplot to open a
separate window for every diagram it creates. Since many times it is
convenient to embed graphs into the work sheet instead wxMaxima
provides its own set of plot functions that don’t differ from the
corresponding maxima functions save in their name: They are all
prepended by a “wx”. For example wxplot
corresponds to
plot
, wxdraw
corresponds to draw
and
wxhistogram
corresponds to histogram
.
2.1.2 Making embedded plots bigger or smaller
The configure dialog provides a way to change the default size plots
are created with which sets the starting value of wxplot_size.
The plotting routines of wxMaxima respect this variable that specifies
the size of a plot in pixels. It can always be queried or used to set
the size of the following plots:
| %i1 wxplot_size:[1200,800];
%o1 [1200,800];
%i2 wxdraw2d(
explicit(
sin(x),
x,1,10
)
)$
|
If the size of only one plot is to be changed maxima provides a
canonical way to change an attribute only for the current cell.
| %i1 wxplot_size:[1200,800];
%o1 [1200,800];
%i1 wxdraw2d(
explicit(
sin(x),
x,1,10
)
),wxplot_size=[1600,800]$
|
2.1.3 Better quality plots
Gnuplot doesn’t seem to provide a portable way of determining is it
supports the high-quality bitmap output the cairo library provides.
On systems where gnuplot is compiled to use this library the
pngcairo option from the configuration menu (that can be overridden
by the variable wxplot_pngcairo) enables support for
antialiasing and additional line styles.
2.1.4 Embedding animations into the spreadsheet
The with_slider_draw
command is a version of wxdraw2d
that does prepare multiple plots and allows to switch between them
by moving the slider on top of the screen. If ImageMagick is installed
wxMaxima even allows to export this animation as an animated gif.
The first two arguments for with_slider_draw
are the name of
the variable that is stepped between the plots and a list of the
values of these variable. The arguments that follow are the ordinary
arguments for wxdraw2d
:
| with_slider_draw(
f,[1,2,3,4,5,6,7,10],
title=concat("f=",f,"Hz"),
explicit(
sin(2*%pi*f*x),
x,0,1
),grid=true
);
|
The same functionality for 3d plots is accessible as with_slider_draw3d
.
There is a second set of functions making use of the slider
-
wxanimate_draw
and
-
wxanimate_draw3d
:
| wxanimate_draw(
a, 3,
explicit(sin(a*x), x, -4, 4),
title=printf(false, "a=~a", a));
|
Normally the animations are played back or exported with the frame
rate chosen in the configuration of wxMaxima. To set the speed an
individual animation is played back the variable wxanimate_framerate
can be used:
| wxanimate(a, 10,
sin(a*x), [x,-5,5]), wxanimate_framerate=6$
|
The animation functions have a pitfall that one has to be aware of when
using them: The slider variable’s value are substituted into the
expression that is to be plotted - which will fail, if the variable
isn’t directly visible in the expression. Therefore the following
example will fail:
| f:sin(a*x);
with_slider_draw(
a,makelist(i/2,i,1,10),
title=concat("a=",float(a)),
grid=true,
explicit(f,x,0,10)
)$
|
If maxima is forced to first evaluate the expression and then asked
to substitute the slider’s value plotting works fine instead:
| f:sin(a*x);
with_slider_draw(
a,makelist(i/2,i,1,10),
title=concat("a=",float(a)),
grid=true,
explicit(''f,x,0,10)
)$
|
2.1.5 Opening multiple plot windows contemporarily
While not being a provided by wxmaxima this feature of maxima (on
setups that support it) sometimes comes in handily. The following
example comes from a post from Mario Rodriguez to the maxima mailing
list:
| load(draw);
/* Parabola in window #1 */
draw2d(terminal=[wxt,1],explicit(x^2,x,-1,1));
/* Parabola in window #2 */
draw2d(terminal=[wxt,2],explicit(x^2,x,-1,1));
/* Paraboloid in window #3 */
draw3d(terminal=[wxt,3],explicit(x^2+y^2,x,-1,1,y,-1,1));
|
2.2 Embedding graphics
if the ‘.wxmx’ file format is being used embedding files in a
wxMaxima project can be done as easily as per drag-and-drop. But
sometimes (for example if an image’s contents might change lateron)
it is better to tell the file to load the image on evaluation:
2.3 wxmaximarc
If the maxima user directory there is a text file named ‘wxmaxima-init.mac’
the contents of the file is passed to maxima automatically every time
a new worksheet has been started.
To find out which directory maxima uses as the user directory just
type in the following line:
The answer from Maxima will specify the name of the directory that the
startup file can be placed in.
| %o1 /home/username/.maxima
|
2.4 Special variables
- wxfilename This variable contains the name of the file
%currently opened in wxMaxima.
- wxplot_pngcairo tells if wxMaxima tries to use gnuplot’s
pngcairo terminal that provides more line styles and a better overall
graphics quality. This variable can be used for reading or overriding
the respective setting in the configuration dialog.
- wxplot_size defines the size of embedded plots.
- wxchangedir On most operating systems wxmaxima
automatically sets maxima’s working directory to the directory
of the current file. This will allow file I/O (e.G. by
read_matrix
) to work without specifying the whole path to the
file that has to be read or written. On windows this is
deactivated, though: The Lisp Standard doesn’t contain a concept of
the current working directory. Therefore there is no standard
way of setting it and changing to a directory that isn’t on
the drive maxima has been installed to might cause maxima to
try to read is own package files from this drive, too, instead
of from the drive maxima has been installed to. Setting
wxchangedir to true
tells wxMmaxima that it has to
risk that and to set maxima’s working directory.
- wxanimate_framerate The number of frames per second the
following animations have to be played back with. -1 tells
wxMaxima to use the default frame rate from the config dialog.
2.5 Pretty-printing 2D output
The function (table_form)
displays a 2D list in a form that is
more readable than the output maxima’s default output routine.
| table_form(
[
[1,2],
[3,4]
]
)$
|
2.6 Bug reporting
wxMaxima provides a few functions that gather bug reporting
information about the current system:
-
wxbuild_info()
gathers information about the currently
running version of wxMaxima
-
wxbug_report()
tells how and where to file bugs
- In special cases additional debugging information might be
obtained by issuing the command
wxmaxima_debug_dump_output
:
Normally this command produces an dialog containing only the
information what would be displayed here if there was something
to display. If there is output
from maxima that isn’t passed to wxMaxima through the network
connection (as it should be) the dialog is filled with this
output instead.
This document was generated by Andrej Vodopivec on April 24, 2015 using texi2html 1.82.