## `plot::contour` -- generate contour and implicit plots

#### Introduction

`plot::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...>)`

#### Parameters

`x, 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)

#### Returns

an object of the domain type `plot::Group`.

#### Options

`Colors` | - | 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 Functions

`plot`, `plot2d`, `plot::density`, `plot::implicit`

#### Details

- Call `plot(...)` to display the contour plot created on the screen.
- The contour lines are drawn on the bottom of the viewing box by default. The result of `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.
- With option `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: Colors

- The default value for `color` is red, the default values for `fromColor` and `toColor` are yellow and red, respectively.

#### Option: Contours

- Giving in integer specifies the number of contour lines to be drawn. This is the default case using eight contour lines.

#### Example 1

The 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 2

If 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 3

We 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
       ))

#### Changes

- used to be called `plotlib::contourplot`
- `plot::contour` is now part of the new plot library `plot`, and its calling syntax and the return value were changed.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000