Quiver
Examples
- Plot vector field :math:
\langle \cos(x)y, \sin(x)y \rangle.
::
let data1 = linspace(0.0, 2.0, num:11)
let (x, y) = meshgrid(data1, data1)
let u = apply2(x, y, {t1: Float64, t2:Float64 => cos(t1) * t2})
let v = apply2(x, y, {t1: Float64, t2:Float64 => sin(t1) * t2})
quiver(x, y, u, v)
Result:
.. image:: ../../../tests/imgs/quiver/quiver_1.png :align: center :width: 360
- Plot vector field with increased length for the vectors.
::
let data1 = linspace(0.0, 2.0, num:11)
let (x, y) = meshgrid(data1, data1)
let u = apply2(x, y, {t1: Float64, t2:Float64 => cos(t1) * t2})
let v = apply2(x, y, {t1: Float64, t2:Float64 => sin(t1) * t2})
quiver(x, y, u, v, scale:2.0)
Result:
.. image:: ../../../tests/imgs/quiver/quiver_2.png :align: center :width: 360
- Plot vector field with very long vectors.
::
let data1 = linspace(0.0, 2.0, num:11)
let (x, y) = meshgrid(data1, data1)
let u = apply2(x, y, {t1: Float64, t2:Float64 => cos(t1) * t2})
let v = apply2(x, y, {t1: Float64, t2:Float64 => sin(t1) * t2})
quiver(x, y, u, v, scale:0.0)
Result:
.. image:: ../../../tests/imgs/quiver/quiver_3.png :align: center :width: 360
- Vector field together with contour.
::
let data1 = linspace(-2.0, 2.0, num:21)
let (x, y, z) = meshgrid(data1, data1, {
x:Float64, y:Float64 => x * exp(-pow(x, 2.0) - pow(y, 2.0))})
let (dx, dy) = gradient(z, spacing_x: 0.2, spacing_y: 0.2)
contour(x, y, z)
hold(true)
quiver(x, y, dx, dy)
Result:
.. image:: ../../../tests/imgs/quiver/quiver_4.png :align: center :width: 360
- Vector field with normalized vector length, custom line width and color map.
::
let data1 = linspace(-2.5, 2.5, num:21)
let (x, y, u) = meshgrid(data1, data1, {
x:Float64, y:Float64 => cos(x) * sin(x + y)})
let v = apply2(x, y, {x: Float64, y: Float64 => sin(y) * cos(x + y)})
let m = apply2(u, v, {u: Float64, v: Float64 => sqrt(u * u + v * v)})
quiver(x, y, u, v, m, scale:0.2).normalize(true).line_width(1.5)
colormap(Palette.Jet)
Result:
.. image:: ../../../tests/imgs/quiver/quiver_5.png :align: center :width: 360