[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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]$

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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(
    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)
)$

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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));

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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:

 
show_image("Mann.png");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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:

 
maxima_userdir;

The answer from Maxima will specify the name of the directory that the startup file can be placed in.

 
%o1 /home/username/.maxima

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4 Special variables


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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]
    ]
)$

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.6 Bug reporting

wxMaxima provides a few functions that gather bug reporting information about the current system:


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Andrej Vodopivec on April 24, 2015 using texi2html 1.82.