Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


ax_draw3d ([args]) — Function

Draw 3D interactive plots using Plotly.js with WebGL rendering. Produces rotatable, zoomable 3D charts.

Supported Draw Objects

ObjectSyntaxDescription
explicitexplicit(expr, x, xlo, xhi, y, ylo, yhi)A surface z=f(x,y)
pointspoints([[x1,y1,z1],...]) or points(xs, ys, zs)3D scatter points
lineslines([[x1,y1,z1],...]) or lines(xs, ys, zs)3D line plot from data

Examples

/* 3D surface */
ax_draw3d(explicit(sin(x)*cos(y), x, -%pi, %pi, y, -%pi, %pi))$

/* 3D scatter */
ax_draw3d(points([[1,1,1],[2,2,4],[3,3,9]]), marker_size=5)$

/* 3D scatter with separate coordinate arrays */
ax_draw3d(points([1,2,3], [4,5,6], [7,8,9]))$

/* 3D line plot from data */
ax_draw3d(lines([[0,0,0],[1,1,1],[2,0,2]]))$

/* 3D line from separate arrays (e.g. ndarrays) */
t : np_linspace(0, 6.28, 200)$
ax_draw3d(lines(np_cos(t), np_sin(t), np_scale(0.1, t)))$

/* With options */
ax_draw3d(
  explicit(x^2 - y^2, x, -2, 2, y, -2, 2),
  title="Saddle Surface",
  colorscale="Viridis"
)$

Style Options

OptionDefaultDescription
colorautoTrace color
opacity1.0Trace opacity
colorscalenoneSurface colorscale (e.g. "Viridis", "Hot")
marker_size6Marker size for scatter points
marker_symbol"circle"Marker shape
nameautoLegend entry
nticks50Grid resolution (nticks x nticks)

Layout Options

OptionDescription
titlePlot title
xlabel / ylabel / zlabelAxis labels
xrange / yrange / zrangeAxis ranges
showlegendShow legend
widthFixed plot width in pixels
heightFixed plot height in pixels

See also: ax_plot2d, ax_draw2d, ax_polar, draw3d