plot3d
Mojo function 🡭
plot3d
fn def plot3d(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[Plot3d]plot3d() 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[Plot3d]: The finished chart – unrendered.
Raises:
Error: A named column is missing, has the wrong dtype for its channel, or has missing values.
fn def plot3d[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[Plot3d]A 3D line: the points joined in data order as one polyline through the viewing cube.
Mark.PLOT3D, scatter3d()’s companion for data with an order –
a trajectory, a path, a parametric curve.
Not depth sorted, and it cannot be: a polyline is one connected path, so reordering its segments by depth would reorder the line itself. A segment passing behind another is drawn over it when it comes later in the series; the fix is splitting segments where they cross in projection, which needs geometry the renderer does not have.
Example:
from std.math import cos, sin
from dataviz import plot3d, save
def main() raises:
# Illustrative trajectory: a spiral tightening as it climbs.
var x = List[Float64]()
var y = List[Float64]()
var z = List[Float64]()
for i in range(200):
var t = Float64(i) * 0.1
var r = 1.0 - Float64(i) * 0.004
x.append(r * cos(t))
y.append(r * sin(t))
z.append(Float64(i) * 0.02)
var c = plot3d(
x, y, z, title="Illustrative Tightening Spiral Trajectory"
)
save(c, "docs/src/examples/out_plot3d.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 z column, 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 – seeTheme’s docstring. - width (
Int): Pixel width of the returnedPlot(.size()). - height (
Int): Pixel height of the returnedPlot(.size()). - title (
String): The chart’s title, shown above the plot. - subtitle (
String): A secondary line shown under the title.
Returns:
Chart[Plot3d]: 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.