Skip to content

Vector Arrows

quiver() over named columns of a dataframe_mojo DataFrame (#743). Each argument names a column instead of holding the values.

Vector Arrows

Usage

from std.math import cos, sin

from dataviz import quiver, save
from dataviz import Theme
from dataviz.core.colormaps import viridis

def main() raises:
    # A circulating flow around the center with a steady drift
    # to the right -- the field a rectangular sampling grid
    # shows as arrows curling around a hub.
    var xs = List[Float64]()
    var ys = List[Float64]()
    var us = List[Float64]()
    var vs = List[Float64]()
    for j in range(12):
        for i in range(16):
            var x = Float64(i) - 7.5
            var y = Float64(j) - 5.5
            xs.append(x)
            ys.append(y)
            us.append(-y * 0.4 + 1.0)
            vs.append(x * 0.4)
    var chart = quiver(
        xs,
        ys,
        us,
        vs,
        color_by_magnitude=True,
        theme=Theme(color_ramp=viridis()),
        title="Illustrative Flow Around a Hub",
        x_title="x",
        y_title="y",
    )
    save(chart, "docs/src/examples/out_quiver.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • x: The numeric column for this channel.
  • y: The numeric column for this channel.
  • u: The numeric column for this channel.
  • v: The numeric column for this channel.
  • scale: See the list overload.
  • color_by_magnitude: See the list overload.
  • theme: See the list overload.
  • width: See the list overload.
  • height: See the list overload.
  • title: See the list overload.
  • subtitle: See the list overload.
  • x_title: See the list overload.
  • y_title: See the list overload.

Related

Related charts: Wind Barbs · Streamlines

Relevant API: quiver