6fbec8f3创建于 2022年6月24日历史提交

Surface

Examples

  1. Plotting a fast-changing surface.

::

let x = linspace(-5.0, 5.0, num: 40)
let y = linspace(-5.0, 5.0, num: 40)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 =>
    20.0 + pow(x, 2.0) - 10.0 * cos(2.0 * PI64 * x) +
           pow(y, 2.0) - 10.0 * cos(2.0 * PI64 * y)})
surf(X, Y, Z)

Result:

.. image:: ../../../tests/imgs/surface/surface_1.png :align: center :width: 360

  1. Plotting the :math:sin(x)+cos(x) function.

::

let x = linspace(1.0, 10.0, num: 30)
let y = linspace(1.0, 20.0, num: 30)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => sin(x) + cos(y)})
surf(X, Y, Z)

Result:

.. image:: ../../../tests/imgs/surface/surface_2.png :align: center :width: 360

  1. Plotting the :math:sin(x)+cos(x) function, with custom coloring, and color-bar shown.

::

let x = linspace(1.0, 10.0, num: 30)
let y = linspace(1.0, 20.0, num: 30)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => sin(x) + cos(y)})
let C = apply2(X, Y, {x: Float64, y: Float64 => x * y})
surf(X, Y, Z, C)
colorbar()

Result:

.. image:: ../../../tests/imgs/surface/surface_3.png :align: center :width: 360

  1. Plotting with custom face alpha and edge color.

::

let x = linspace(-5.0, 5.0, num:30)
let (X, Y, Z) = meshgrid(x, x, {x: Float64, y: Float64 => y * sin(x) - x * cos(y)})
surf(X, Y, Z).face_alpha(0.5).edge_color("none")

Result:

.. image:: ../../../tests/imgs/surface/surface_4.png :align: center :width: 360

  1. Plotting with lighting on.

::

let x = linspace(1.0, 10.0, num: 30)
let y = linspace(1.0, 20.0, num: 30)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => sin(x) + cos(y)})
surf(X, Y, Z).lighting(true)

Result:

.. image:: ../../../tests/imgs/surface/surface_5.png :align: center :width: 360

  1. Plotting with lighting on and no edge color.

::

let x = linspace(1.0, 10.0, num: 30)
let y = linspace(1.0, 20.0, num: 30)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => sin(x) + cos(y)})
surf(X, Y, Z).edge_color("none").lighting(true)

Result:

.. image:: ../../../tests/imgs/surface/surface_6.png :align: center :width: 360

  1. This example shows the effect of drawing a flat surface.

::

let x = linspace(1.0, 10.0, num: 19)
let y = linspace(1.0, 20.0, num: 20)
let (X, Y, Z) = meshgrid(x, y, {x: Float64, y: Float64 => 5.0})
surf(X, Y, Z)

Result:

.. image:: ../../../tests/imgs/surface/surface_7.png :align: center :width: 360