This script cube.R allows for 3D phase plane analysis, by defining the functions cube() and run3d() that both use the plot3D library. The call to cube() is similar to the call to plane(). The cube.R script can be downloaded from the Grind directory. There are three extra options:
1. shade="xyx" allows one to shade nullclines in the x, y, and/or z direction. The shading is off by default (shade="").
2. box=FALSE suppresses the drawing of the upper edges of the cube.
3. grid=5 defines that 5 lines are used in the shading.

The viewpoint is defined by the defaults theta=40 and phi=40, where theta gives the azimuthal direction and phi the colatitude. One can use plotdev(theta=60,phi=40) to change the viewpoint afterwards. It is typically good top set par(mar=c(0,0,0,0)) to reduce the margins.

The tutorial chaos3d provides and example of calling cube() and plot3d().

After also installing the rgl and the plot3Drgl R-packages, one can call the plotrgl() function to open a new window in which the graphics can be rotated and zoomed with the mouse (try using the left and right buttons).

Finally, if one prefers to have the origin in the left hand back corner, with x pointing rightwards, y upwards, and z forwards, call cube() and run3d() with (x=3, y=1, z=2, theta=130, ...).

cube <- function(x=1, y=2, z=3, xmin=0.001, xmax=1.05, ymin=0.001, ymax=1.05, zmin=0.001, zmax=1.05, xlab="", ylab="", zlab="", log="", shade="", grid=5, npixels=150, state=s, parms=p, odes=model, time=0, show=NULL, zero=TRUE, add=FALSE, box=FALSE, lwd=1, ...) { }
  
run3d <- function(x=1, y=2, z=3, xmin=0.001, xmax=1.05, ymin=0.001, ymax=1.05, zmin=0.001, zmax=1.05, log="", col=1, add=FALSE, state=s, parms=p, ...) { }