Plot surfaces and trajectories
Compose native spatial surfaces and trajectories with explicit labels and portable output.
// Requires the matching spatial-plot-enabled native development runtime.
import aner.plot
import aner.math
// A parametric path connects samples in their original order.
let pathX = List()
let pathY = List()
let pathZ = List()
for sample in Range(81) {
let t = Float64(sample) * 0.15707963267948966
pathX.append(math.cos(t))
pathY.append(math.sin(t))
pathZ.append(t / 6.283185307179586)
}
let trajectory = plot.line3d(pathX, pathY, pathZ)
.labels("x (m)", "y (m)", "z (m)").aspect("equal")
.view(-35.0, 25.0).title("A supplied helix connects 81 ordered samples")
.caption("Synthetic parametric path: x=cos(t), y=sin(t), z=t/(2π), 0≤t≤4π. No smoothing, fitted trajectory or physical simulation.")
.theme(plot.theme("light")).size(940, 640)
trajectory.show()
// Surface axes are strictly increasing; z is row-major, one row per y.
let gridX = List()
let gridY = List()
let gridZ = List()
for column in Range(21) { gridX.append(-2.0 + Float64(column) * 0.2) }
for row in Range(17) { gridY.append(-2.0 + Float64(row) * 0.25) }
for row in Range(17) {
let y = -2.0 + Float64(row) * 0.25
for column in Range(21) {
let x = -2.0 + Float64(column) * 0.2
gridZ.append((x * x - y * y) / 4.0)
}
}
let saddle = plot.surface3d(x: gridX, y: gridY, z: gridZ)
.labels("x (m)", "y (m)", "Response (arbitrary units)")
.color_label("Response (arbitrary units)").color_limits(-1.0, 1.0)
.aspect("auto").view(-45.0, 30.0)
.title("An explicitly sampled saddle surface")
.caption("Synthetic z=(x²−y²)/4 on a 17×21 rectangular grid. Flat triangles join supplied neighboring vertices; no fitted surface. Auto aspect normalizes each axis independently.")
.theme(plot.theme("light")).size(1000, 680)
saddle.show()
// Export initial native views, using fresh filenames.
trajectory.save("spatial-trajectory.html")
trajectory.save("spatial-trajectory.svg")
saddle.save("spatial-surface.html")
saddle.save("spatial-surface.svg")
Run step by step in VS Code.
The notebook separates CSV loading or observations and 3D chart construction into cells. It opens with empty outputs and shared variables, and needs no map packs.
- Install a compatible native Aner executable and VS Code extension using the editor guide. 3D chart construction and local rotation require the Aner 0.0.3 or newer runtime and editor.
- Download the
.anernbnotebook and open it in your VS Code project. If it appears as JSON, choose Reopen Editor With… → Aner Notebook. - Select the
Aner — notebookkernel and keep Shared variables active. Run code cells from top to bottom, or choose Run All. Later cells reuse the captured observations and chart values from earlier cells. - Read the 3D plot below its producing cell. Drag inside the plot to orbit, or use Rotate plot X/Y/Z controls. Reset view restores the source angles and zoom. Rotation and zoom keep the captured data and scales unchanged.
After changing an earlier cell, rerun its dependent cells. Use Aner: Restart Notebook Session, then Run All, for a clean experiment. Saved outputs are historical; reopening the file starts without live variables. The notebook guide explains session state, inspection, and runtime controls.
Make it your experiment.
Use Aner 0.0.3 or newer. Save this program as examples/plot_spatial3d.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/plot_spatial3d.aner
aner run examples/plot_spatial3d.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.0.4 or newer supporting Cartesian 3D plots and the matching VS Code extension for .anernb. The supplied analysis needs no map pack, credentials, server or connection. Native source and the Aner notebook share the same analysis. Source export uses fresh HTML and SVG filenames; existing files are never overwritten.
aner check examples/plot_spatial3d.aner
aner run examples/plot_spatial3d.anerThese observations are synthetic Cartesian teaching inputs; their units and coordinate conventions are stated in the example. They are not terrain or municipal measurements. Rotation changes only the view, and needs no map packs.
Read the 3D chart contracts