Search code examples
plotmaxima

Maxima: Colorplot of 2D scalar field f(x,y) (aka "bird's view")


In maxima, the default behavior when invoking the plot3d() function is to show the resulting manifold from the side in perspective. For instance, running

(%i0) wxplot3d(cos(x)*cos(y),[x,-%pi,%pi],[y,-%pi,%pi]);

yields

Maxima's default behaviour is to show the plot from the side.

Such plots can be very pretty but tend to biaise our interpretation of it and also sometimes parts of the manifold are hidden. How do I get a "bird's view" of the same plot?


Solution

  • This can be achieved by asking Maxima to run gnuplot's set view map command before drawing the plot. Indeed, calling

    (%i0) wxplot3d(cos(x)*cos(y),[x,-%pi,%pi],[y,-%pi,%pi], [gnuplot_preamble, "set view map"]);
    

    yields

    enter image description here

    An alternative to the color plot is the contour plot. For instance,

    (%i1) wxplot3d(cos(x)*cos(y),[x,-%pi,%pi],[y,-%pi,%pi], [gnuplot_preamble,
        "set view map; set size square;unset surface;set contour;set cntrparam levels 10;set clabel '%.1f';set isosamples 150"])
    

    yields

    enter image description here

    Those parameters are the ones recommended by the "Gnuplot in Action" book, page 145, Listing 8.1. Here is a description of what each does (from the very same listing):

    set view map            #Choose birds-eye view
    set size square         #Choose equal units in both directions
    unset surface           #Switch off the surface...
    set contour             #... but switch on contours lines
    set cntrparam levels 10 #Increase the number of contour lines
    set clabel "%.1f"       #Choose format of contour labels in key
    set isosamples 150      #Increase sampling frequency