Skip to content

quiver3d

Mojo function 🡭

quiver3d

fn def quiver3d(df: DataFrame, x: String, y: String, z: String, u: String, v: String, w: String, elev: Float64 = 30, azim: Float64 = -60, theme: Theme = Theme(WHITE, Color(UInt8(30), UInt8(100), UInt8(180), UInt8(255)), Color(UInt8(80), UInt8(80), UInt8(80), UInt8(255)), Color(UInt8(225), UInt8(225), UInt8(225), UInt8(255)), Color(UInt8(40), UInt8(40), UInt8(40), UInt8(255)), SIMD(12), SIMD(3.5), SIMD(2), Int(60), Int(20), Int(20), Int(50), True, False, False, Color(UInt8(240), UInt8(240), UInt8(240), UInt8(255)), Int(3), Color(UInt8(60), UInt8(110), UInt8(200), UInt8(255)), Color(UInt8(235), UInt8(235), UInt8(235), UInt8(255)), Color(UInt8(220), UInt8(90), UInt8(40), UInt8(255)), ColorRamp(), ColorPalette(), SIMD(3), SIMD(15), True, SIMD(1), Int(0), False, Color(UInt8(200), UInt8(60), UInt8(60), UInt8(255)), Color(UInt8(224), UInt8(224), UInt8(224), UInt8(255)), Color(UInt8(120), UInt8(120), UInt8(120), UInt8(255)), Color(UInt8(100), UInt8(100), UInt8(100), UInt8(255)), Color(UInt8(230), UInt8(230), UInt8(230), UInt8(255)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), UInt8(90), UInt8(160), False, False, SIMD(0), SIMD(18), SIMD(14), Color(UInt8(110), UInt8(110), UInt8(110), UInt8(255)), SIMD(14), Color(UInt8(150), UInt8(150), UInt8(150), UInt8(255)), Color(UInt8(224), UInt8(236), UInt8(246), UInt8(200)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), True, False, False, True, AxisPosition.EDGE, AxisPosition.EDGE, String("sans-serif"), True, UInt8(90), Int(5), Int(4), Int(130), Int(14), Int(8), Int(14), Int(100), Int(8), SIMD(4), OutputFormat.SVG, Tooltips.AUTO, Missing.DRAW, String("(missing)"), Int(1000), False, LineStyle.SOLID, SIMD(1.5), LineStyle.SOLID, LegendPosition.RIGHT, XAxisLabelRotation.AUTO, TickFormat.AUTO, TickFormat.AUTO), width: Int = Int(640), height: Int = Int(480), title: String = "", subtitle: String = "") -> Chart[Quiver3d]

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

See Plot.encode_frame() for how columns are read and what a column with missing values does.

Args:

  • df (DataFrame): The frame to read.
  • x (String): The numeric column for this channel.
  • y (String): The numeric column for this channel.
  • z (String): The numeric column for this channel.
  • u (String): The numeric column for this channel.
  • v (String): The numeric column for this channel.
  • w (String): The numeric column for this channel.
  • elev (Float64): See the list overload.
  • azim (Float64): See the list overload.
  • theme (Theme): See the list overload.
  • width (Int): See the list overload.
  • height (Int): See the list overload.
  • title (String): See the list overload.
  • subtitle (String): See the list overload.

Returns:

Chart[Quiver3d]: The finished chart – unrendered.

Raises:

Error: A named column is missing, has the wrong dtype for its channel, or has missing values.

fn def quiver3d[dtype: DType](x: List[Scalar[dtype]], y: List[Scalar[dtype]], z: List[Scalar[dtype]], u: List[Scalar[dtype]], v: List[Scalar[dtype]], w: List[Scalar[dtype]], elev: Float64 = 30, azim: Float64 = -60, theme: Theme = Theme(WHITE, Color(UInt8(30), UInt8(100), UInt8(180), UInt8(255)), Color(UInt8(80), UInt8(80), UInt8(80), UInt8(255)), Color(UInt8(225), UInt8(225), UInt8(225), UInt8(255)), Color(UInt8(40), UInt8(40), UInt8(40), UInt8(255)), SIMD(12), SIMD(3.5), SIMD(2), Int(60), Int(20), Int(20), Int(50), True, False, False, Color(UInt8(240), UInt8(240), UInt8(240), UInt8(255)), Int(3), Color(UInt8(60), UInt8(110), UInt8(200), UInt8(255)), Color(UInt8(235), UInt8(235), UInt8(235), UInt8(255)), Color(UInt8(220), UInt8(90), UInt8(40), UInt8(255)), ColorRamp(), ColorPalette(), SIMD(3), SIMD(15), True, SIMD(1), Int(0), False, Color(UInt8(200), UInt8(60), UInt8(60), UInt8(255)), Color(UInt8(224), UInt8(224), UInt8(224), UInt8(255)), Color(UInt8(120), UInt8(120), UInt8(120), UInt8(255)), Color(UInt8(100), UInt8(100), UInt8(100), UInt8(255)), Color(UInt8(230), UInt8(230), UInt8(230), UInt8(255)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), UInt8(90), UInt8(160), False, False, SIMD(0), SIMD(18), SIMD(14), Color(UInt8(110), UInt8(110), UInt8(110), UInt8(255)), SIMD(14), Color(UInt8(150), UInt8(150), UInt8(150), UInt8(255)), Color(UInt8(224), UInt8(236), UInt8(246), UInt8(200)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), True, False, False, True, AxisPosition.EDGE, AxisPosition.EDGE, String("sans-serif"), True, UInt8(90), Int(5), Int(4), Int(130), Int(14), Int(8), Int(14), Int(100), Int(8), SIMD(4), OutputFormat.SVG, Tooltips.AUTO, Missing.DRAW, String("(missing)"), Int(1000), False, LineStyle.SOLID, SIMD(1.5), LineStyle.SOLID, LegendPosition.RIGHT, XAxisLabelRotation.AUTO, TickFormat.AUTO, TickFormat.AUTO), width: Int = Int(640), height: Int = Int(480), title: String = "", subtitle: String = "") -> Chart[Quiver3d]

Arrows in space: a direction and a magnitude sampled at points.

Mark.QUIVER3D. Each arrow runs from its (x, y, z) along (u, v, w), in the data’s own units, so its length is read against the axes.

The box is fitted to the arrows’ tips as well as their tails – an arrow leaving the box would read as pointing at something outside the data.

An arrow pointing near the viewer projects to almost nothing, and no view avoids that for every arrow at once. Where the field’s structure matters more than any one arrow, a streamplot of a slice through it shows more.

Example:

from dataviz import quiver3d, save

def main() raises:
    # Illustrative circulation: a field turning about the z axis
    # and drifting upward as it goes.
    var x = List[Float64]()
    var y = List[Float64]()
    var z = List[Float64]()
    var u = List[Float64]()
    var v = List[Float64]()
    var w = List[Float64]()
    for k in range(3):
        for j in range(3):
            for i in range(3):
                var px = Float64(i) - 1.0
                var py = Float64(j) - 1.0
                var pz = Float64(k) - 1.0
                x.append(px)
                y.append(py)
                z.append(pz)
                u.append(-py * 0.35)
                v.append(px * 0.35)
                w.append(0.25)

    var c = quiver3d(
        x, y, z, u, v, w, title="Illustrative Circulating Field"
    )
    save(c, "docs/src/examples/out_quiver3d.svg")

Parameters:

  • dtype (DType)

Args:

  • x (List[Scalar[dtype]]): The x coordinate of each arrow’s tail.
  • y (List[Scalar[dtype]]): The y coordinate of each tail, the same length.
  • z (List[Scalar[dtype]]): The z coordinate of each tail, the same length.
  • u (List[Scalar[dtype]]): The x component of each arrow, the same length.
  • v (List[Scalar[dtype]]): The y component, the same length.
  • w (List[Scalar[dtype]]): The z component, the same length.
  • elev (Float64): Degrees to look down on the scene from, above the x-y plane.
  • azim (Float64): Degrees to turn the scene through, about the z axis.
  • theme (Theme): Full styling knobs beyond this function’s own parameters – see Theme’s docstring.
  • width (Int): Pixel width of the returned Plot (.size()).
  • height (Int): Pixel height of the returned Plot (.size()).
  • title (String): The chart’s title, shown above the plot.
  • subtitle (String): A secondary line shown under the title.

Returns:

Chart[Quiver3d]: The finished chart – unrendered. Call save(plot, path) to write it (any of .svg/.png/.pdf/.bmp), or render(plot)/render_svg(plot) for the explicit two-step.

Raises:

Error: The six columns disagree in length, or are empty.