Sponsored links: Algebra eBooks ### The Maxima on-line user's manual

Algebra Calculator

#### Search: #### Plot3d

Function: plot3d (<expr>, <x_range>, <y_range>, ..., <options>, ...) Function: plot3d ([<expr_1>, ..., <expr_n>], <x_range>, <y_range>, ..., <options>, ...) Displays a plot of one or more surfaces defined as functions of two variables or in parametric form.

The functions to be plotted may be specified as expressions or function names. The mouse can be used to rotate the plot looking at the surface from different sides.

*Examples:*

```     Plot of a common function:
(%i1) plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2])\$```

Use of the z option to limit a function that goes to infinity (in this case the function is minus infinity on the x and y axes); this also shows how to plot with only lines and no shading:

`          (%i1) plot3d ( log ( x^2*y^2 ), [x, -2, 2], [y, -2, 2], [z, -8, 4],`
`                   [palette, false], [color, magenta, blue])\$`

The infinite values of z can also be avoided by choosing a grid that does not fall on any asymptotes; this example also shows how to select one of the predefined palettes, in this case the fourth one:

`          (%i1) plot3d(log(x^2*y^2), [x, -2, 2], [y, -2, 2], [grid, 29, 29],`
`                [palette, get_plot_option(palette,5)])\$`

Two surfaces in the same plot, sharing the same domain; in gnuplot the two surfaces will use the same palette:

`          (%i1) plot3d ( [2^(-x^2 + y^2), 4*sin(3*(x^2+y^2))/(x^2+y^2),`
`                   [x, -3, 3], [y, -2, 2]])\$`

The same two surfaces, but now with different domains; in xmaxima each surface will use a different palette, chosen from the list defined by the option palette:

`          (%i1) plot3d ( [[2^(-x^2 + y^2),[x,-2,2],[y,-2,2]],`
`                   4*sin(3*(x^2+y^2))/(x^2+y^2), [x, -3, 3], [y, -2, 2]],`
`                   [plot_format,xmaxima])\$`

```     Plot of a Klein bottle, defined parametrically:
(%i1) e_1: 5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0)-10.0\$
(%i2) e_2: -5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0)\$
(%i3) e_3: 5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))\$
(%i4) plot3d ([e_1, e_2, e_3], [x, -%pi, %pi],
[y, -%pi, %pi], [grid, 40, 40])\$```

Plot of a spherical harmonic, using of the predefined transformations, `spherical_to_xyz`, to transform from spherical to rectangular coordinates. See the documentation for `spherical_to_xyz`.

`          (%i1) plot3d (sin(2*theta)*cos(phi), [theta,0,%pi], [phi,0,2*%pi],`
`                  [transform_xy, spherical_to_xyz], [grid,30,60])\$`

Use of the predefined function `polar_to_xy` to transform from cylindrical to rectangular coordinates. See the documentation for `polar_to_xy`. This example also shows how to eliminate the bounding box and the legend.

`          (%i1) plot3d(r^.33*cos(th/3), [r,0,1], [th,0,6*%pi], [grid,12,80],`
`                 [transform_xy, polar_to_xy], [box, false], [legend,false])\$`

Plot of a sphere using the transformation from spherical to rectangular coordinates. In xmaxima the three axes are scaled in the same proportion, maintaining the symmetric shape of the sphere. A palette with different shades of a single color is used:

`          (%i1) plot3d (5, [theta, 0, %pi], [phi, 0, 2*%pi],`
`           [transform_xy, spherical_to_xyz], [plot_format,xmaxima],`
`           [palette,[value,0.65,0.7,0.1,0.9]])\$`

Definition of a function of two-variables using a matrix. Notice the single quote in the definition of the function, to prevent plot3d from failing when it realizes that the matrix will require integer indices.

`          (%i1) M: matrix([1,2,3,4], [1,2,3,2], [1,2,3,4], [1,2,3,3])\$`
`          (%i2) f(x, y) := float(M [round(x), round(y)])\$`
`          (%i3) plot3d (f(x,y), [x, 1, 4], [y, 1, 4], [grid, 4, 4])\$`
`          apply: subscript must be an integer; found: round(x)`

By setting the elevation equal to zero, a surface can be seen as a map in which each color represents a different level. The option `colorbox` is used to show the correspondence among colors and levels, and the mesh lines are disabled to make the colors easier to see.

`          (%i1) plot3d (cos (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4],`
`                  [mesh_lines_color, false], [elevation, 0], [azimuth, 0],`
`                  [colorbox, true], [grid, 150, 150])\$`

```(%o1)                                true
(%i2) ```

### Related Examples

##### plot3d plot3d ((z-z^4)^(1/4)...

Calculate

##### plot3d f(x,y):= 32-x^2-4*y^2;

plot3d(f(x,y), [x,-5,...

Calculate

##### plot3d-sqrt f(x,y):= sqrt((16*y-x...

plot3d(x^2+y^2,[x,-2,...

Calculate

##### plot3d plot3d(x^2*y/(x^4+y^2...

Calculate

##### plot3d-sin-sqrt f(x,y):= sin(x^2)-sqr...

plot3d(f(x,y), [x,-5,...

Calculate

##### plot3d-sqrt a=2;

b=2;

c=1;

Calculate

##### plot3d plot3d([ [0.9999476*y...

Calculate

##### plot3d-sin plot3d(sin(x)*sin(x-y...

Calculate

##### plot3d plot3d([ [0.9999476*y...

Calculate

##### plot3d-sin plot3d(sin(x+y),[x,-5...

Calculate 