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

Ribbon

Examples

  1. Plot peaks function as a ribbon graph.

::

let x = linspace(-3.0, 3.0, num:13)
let y = linspace(-3.0, 3.0, num:61)
let (X, Y, Z) = meshgrid(x, y, peaks)
ribbon(X, Y, Z)

Result:

.. image:: ../../../tests/imgs/ribbon/ribbon_1.png :align: center :width: 360

  1. Plot ribbon graph with custom coloring and full width.

::

let x = linspace(-3.0, 3.0, num:13)
let y = linspace(-3.0, 3.0, num:61)
let (X, Y, Z) = meshgrid(x, y, peaks)
let (FX, FY) = gradient(Z, spacing_x: 6.0 / 49.0, spacing_y: 6.0 / 49.0)
ribbon(X, Y, Z, FX, width:1.0)
colorbar()

Result:

.. image:: ../../../tests/imgs/ribbon/ribbon_2.png :align: center :width: 360

  1. Plot ribbon graph with custom edge color and face alpha.

::

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)})
ribbon(X, Y, Z).edge_color("green").face_alpha(0.5)

Result:

.. image:: ../../../tests/imgs/ribbon/ribbon_3.png :align: center :width: 360

  1. Plot the Rastrigin function as a ribbon graph.

::

let rastrigin = {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)}
let x = linspace(-5.0, 5.0, num:11)
let y = linspace(-5.0, 5.0, num:40)
let (X, Y, Z) = meshgrid(x, y, rastrigin)
ribbon(X, Y, Z).face_alpha(0.8)

Result:

.. image:: ../../../tests/imgs/ribbon/ribbon_4.png :align: center :width: 360