Skip to content

trisurf3d

Mojo function 🡭

trisurf3d

fn def trisurf3d(df: DataFrame, x: String, y: String, z: 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[Trisurf3d]

trisurf3d() 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.
  • 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[Trisurf3d]: The finished chart – unrendered.

Raises:

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

fn def trisurf3d[dtype: DType](x: List[Scalar[dtype]], y: List[Scalar[dtype]], z: 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[Trisurf3d]

A 3D surface over scattered points: the (x, y) are triangulated, lifted to their z, and filled.

Mark.TRISURF3D. Use it when the samples do not sit on a grid – survey points, sensor sites, anywhere the measurements landed where they landed. On gridded data surface3d is the same picture without a triangulation to compute.

The triangulation covers the convex hull of the points, so a concave sampled region gets filled across the gap. It is a height field besides: one z per (x, y), so no overhang can be drawn.

Example:

from std.math import cos, sin, sqrt

from dataviz import save, trisurf3d

def main() raises:
    # Illustrative survey: samples off the grid, spread over a
    # disc by the golden angle so the density is even.
    var x = List[Float64]()
    var y = List[Float64]()
    var z = List[Float64]()
    for i in range(400):
        var t = Float64(i) * 2.399963
        var r = 0.16 * sqrt(Float64(i))
        var px = r * cos(t)
        var py = r * sin(t)
        x.append(px)
        y.append(py)
        z.append(0.8 * sin(px * 1.1) * cos(py * 1.1))

    var c = trisurf3d(
        x, y, z, title="Illustrative Survey Sampled Off the Grid"
    )
    save(c, "docs/src/examples/out_trisurf3d.svg")

Parameters:

  • dtype (DType)

Args:

  • x (List[Scalar[dtype]]): The x column.
  • y (List[Scalar[dtype]]): The y column, the same length.
  • z (List[Scalar[dtype]]): The height at each point, 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[Trisurf3d]: 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 three columns disagree in length, or are empty.