plot::contour -- generate
contour and implicit plots
Introductionplot::contour([x, y, z], u = a..b, v =
c..d) returns a contour plot of the surface defined by
(u,v) -> (x(u,v); y(u,v); z(u,v)) with (u,v) in
[a,b] x [c,d].
Call(s)plot::contour([x, y, z], u = a..b, v = c..d <, option1,
option2...>)
Parametersx, y, z |
- | arithmetical expressions in u and
v |
u, v |
- | identifiers |
option1, option2, ... |
- | plot option(s) of the form option =
value, including the special plot options Colors and Contours (see below) |
Returnsan object of the domain type plot::Group.
OptionsColors |
- | either the list [Flat <, color>],
[Height <, fromColor, toColor>] or
[Curve,color1...], where color,
fromColor, toColor and color1...
are RGB color specifications, i.e., lists of three real numerical
values between 0 and 1. |
Contours |
- | either an integer greater than two, or a list of the form [r[1],...,r[n]] of real numerical values. |
Related
Functionsplot, plot2d, plot::density, plot::implicit
Detailsplot(...) to display the contour plot created on
the screen.plot::contour is a two-dimensional
object, and the plot options option1,
option2... must be valid plot options for two-dimensional
graphical objects. See plot2d for details.Style = Attached, the contour lines are
drawn with respect to the height of the surface which results in a
graphical object of dimension three.
Here, the plot options option1, option2...
must be valid plot options for three-dimensional graphical objects. See
plot3d for details.
Note that scene options are not allowed! You may
give scene options as optional arguments for the function plot, or use plot::Scene to create an object
representing a graphical scene.
Option: Colorscolor is red, the default values
for fromColor and toColor are yellow and red,
respectively.
Option: Contours
Example
1The following call returns an object representing a contour plot of the surface defined by (u,v) -> (u, v, exp(u*v) with (u,v) in [-1,1] x [-1,1]:
>> c:= plot::contour([x, y, exp(x*y)], x = -1..1, y = -1..1)
plot::Group()
To plot this object on the screen, call plot:
>> plot(c)
With the option Style = Attached, we get
the following three-dimensional contour plot of the same surface:
>> plot(plot::contour(
[x, y, exp(x*y)], x = -1..1, y = -1..1, Style = Attached
))
If you want to color the contour plot with respect to the height of the surface, you may enter:
>> plot(plot::contour(
[x, y, exp(x*y)], x = -1..1, y = -1..1, Colors=[Height]
))
Here, the default color values from red to yellow are used.
Example
2If you want to plot multiple contour plots in a single graphical scene, first create the desired contour plots, such as:
>> c1:= plot::contour(
[x, y, sin(x*y)], x = -PI..PI, y = -PI..PI, Grid = [20,20]
):
c2:= plot::contour(
[x, y, x + 2*y], x= -PI..PI, y = -PI..PI, Colors=[Flat,RGB::Blue]
):
and collect them into a single graphical scene:
>> plot(c1, c2)
Example
3We plot the implicit function defined by (x^2 + y^2)^3 - (x^2 - y^2)^2 = 0:
>> plot(plot::contour(
[x, y, (x^2 + y^2)^3 - (x^2 - y^2)^2], x = -1..1, y = -1..1,
Contours=[0], Grid=[20,20]
))
Anyway, you may prefer the function plot::implicit that is used to plot
graphs of implicit functions and therefore usually yields better
results:
>> plot(plot::implicit(
(x^2 + y^2)^3 - (x^2 - y^2)^2, x = -1..1, y = -1..1
))
plotlib::contourplotplot::contour is now part of the new plot library
plot, and its calling
syntax and the return value were changed.