Contour
Examples
- Plot contour of function :math:
sin(x)+cos(y).
::
let x = linspace(-2.0 * PI64, 2.0 * PI64)
let y = linspace(0.0, 4.0 * PI64)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => sin(x) + cos(y)})
contour(X, Y, Z)
Result:
.. image:: ../../../tests/imgs/contour/contour_1.png :align: center :width: 360
- Plot contour of the peaks function.
::
let x = linspace(-3.0, 3.0, num: 50)
let (X, Y, Z) = meshgrid(x, x, peaks)
contour(X, Y, Z, 20)
Result:
.. image:: ../../../tests/imgs/contour/contour_2.png :align: center :width: 360
- Plot contour of the peaks function, with single level set at 1.0.
::
let x = linspace(-3.0, 3.0, num: 50)
let (X, Y, Z) = meshgrid(x, x, peaks)
contour(X, Y, Z, vector([1.0]))
Result:
.. image:: ../../../tests/imgs/contour/contour_3.png :align: center :width: 360
- Plot contour of the peaks function, with dashed level sets.
::
let x = linspace(-3.0, 3.0, num: 50)
let (X, Y, Z) = meshgrid(x, x, peaks)
contour(X, Y, Z, line_spec:"--")
Result:
.. image:: ../../../tests/imgs/contour/contour_4.png :align: center :width: 360
- Plot contour with labels for each level set.
::
let x = linspace(-3.0, 3.0, num: 46)
let y = linspace(-3.0, 3.0, num: 46)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 =>
x * exp(-pow(x, 2.0) - pow(y, 2.0))})
contour(X, Y, Z).contour_text(true)
Result:
.. image:: ../../../tests/imgs/contour/contour_5.png :align: center :width: 360
- Plot contour with custom line width.
::
let x = linspace(-3.0, 3.0, num: 50)
let (X, Y, Z) = meshgrid(x, x, peaks)
contour(X, Y, Z).line_width(3.0)
Result:
.. image:: ../../../tests/imgs/contour/contour_6.png :align: center :width: 360
- Plot contour with labels for each level set, custom font size, color, and weight.
::
let x = linspace(-3.0, 3.0, num: 50)
let (X, Y, Z) = meshgrid(x, x, peaks)
let c: Contours = contour(X, Y, Z)
c.contour_text(true)
c.font_size(15.0)
c.font_color("blue")
c.font_weight("bold")
Result:
.. image:: ../../../tests/imgs/contour/contour_7.png :align: center :width: 360
- This example shows the effect of NaN in the data.
::
let x = linspace(-3.0, 3.0, num: 49)
let (X, Y, Z) = meshgrid(x, x, peaks)
for (i in 0..49) {
Z[i,25] = NaN64
}
contour(X, Y, Z).contour_text(true)
Result:
.. image:: ../../../tests/imgs/contour/contour_8.png :align: center :width: 360