Contour Plots

Copyright 1998, 2001 by James F. Hurley, University of Connecticut Department of Mathematics, Unit 3009, Storrs CT 06269-3009. All rights reserved.

Maple can generate plots of level curves for functions of two and three variables, The syntax is similar to Mathematica's. The following short routine illustrates this for the function f : R^2 R with formula f(x,y) = x^2+y^2 . As usual, execute the routine by placing the cursor after the last line of code and pressing the Enter key at the lower right of the keyboard.

> with(plots):
f := (x, y) -> x^2 + y^2:
contourplot( f(x, y), x = -4..4, y = -4..4 );


The curves, which of course are circles with center at the origin, appear elliptical. This is due to different scaling on the two coordinate axes. To correct that, Maple has a special plotting option
scaling = constrained , which forces identical scales on the coordinate axes. To apply it, simply add that option to the contourplot command:

> with(plots):
f := (x, y) -> x^2 + y^2:
contourplot( f(x, y), x = -4..4, y = -4..4, scaling = constrained);

Warning, the name changecoords has been redefined

[Maple Plot]


Another plotting command of this type,
densityplot , produces a grayscale graph, the lighter areas of which correspond to function values of larger size. This can be useful in estimating whether a function has a discontinuity near a point ( a, b, f ( a, b )). The following routine illustrates the discontinuity of the function g whose value is (x^2+y^3)/(x^2+y^2) , for (x, y) <> (0, 0) and whose value at the origin is 0. The plot indicates that as (x, y) approaches the origin along or near the y-axis, the values of the function are very much larger than those along the x -axis.

> with(plots):
g := (x, y) -> piecewise(x <> 0 and y <> 0,(x^2 + y^3)/(x^2 + y^2), 0);
densityplot( g(x, y), x = -1..1, y = -1..1, grid = [25, 25] );

g := proc (x, y) options operator, arrow; piecewise...

[Maple Plot]

Three-dimensional contour plots.


Maple can also give a three-dimensional plot of the graph of a function
f : R^2 R , and display the level curves at their various z -heights in three-space. To make such a plot, use the three-dimensional contourplot3d command. The following routine illustrates this command, which notice is fundamentally different from the corresponding command in Mathematica. (That gives plots of level surfaces of functions of three variables.)

> f := (x, y) -> x^2 + y^2 ;
contourplot3d( f(x, y),x = -5..5, y = -5..5, color = blue, labels = ["x", "y", "z"], axes = boxed);

f := proc (x, y) options operator, arrow; x^2+y^2 e...

[Maple Plot]