anyplotlib.Plot3D#
- class anyplotlib.Plot3D(geom_type, x, y, z, *, colormap='viridis', color='#4fc3f7', colors=None, point_size=4.0, linewidth=1.5, x_label='x', y_label='y', z_label='z', azimuth=-60.0, elevation=30.0, zoom=1.0, bounds=None, voxel_size=1.0, alpha=None, gpu='auto')[source]#
Bases:
_BasePlot3-D plot panel.
Supports four geometry types:
'surface'– triangulated surface, Z-coloured via colormap.'scatter'– point cloud; single colour or per-pointcolors.'line'– connected line through 3-D points.'voxels'– shaded translucent cubes at the given centres; voxels lying on aPlaneWidgetslice render more opaque.
A single point can be emphasised with
set_highlight()(e.g. the “current” orientation in an IPF explorer), andbounds=fixes the axes extents for origin-true geometry such as unit vectors on a sphere. DraggablePlaneWidgetslice selectors are added withadd_widget().Created by
Axes.plot_surface(),Axes.scatter3d(), andAxes.plot3d().Not an anywidget. Holds state in
_statedict; every mutation calls_push()which writes to the parent Figure’s panel trait.- Parameters:
- add_widget(kind, **kwargs)[source]#
Add an interactive overlay widget to this 3-D panel.
Currently supports
"plane"— a draggable axis-aligned slice plane (seePlaneWidget):pw = vol.add_widget("plane", axis="z", position=24) @pw.add_event_handler("pointer_move") def on_drag(event): resliced(int(round(pw.position)))
- Parameters:
kind (str)
- property gpu_active: bool#
Trueif this panel is currently rendering geometry on the GPU.Reflects the JS renderer’s decision after the first frame: WebGPU is used only when available and when the panel’s
gpupolicy and point count call for it. AlwaysFalseon the Canvas2D fallback path (nonavigator.gpu, no adapter, device lost, orgpu=False).
- set_colormap(name)[source]#
Set the surface colormap (ignored for scatter/line).
- Parameters:
name (str)
- Return type:
None
- set_view(azimuth=None, elevation=None)[source]#
Set the camera azimuth (°) and/or elevation (°).
Uses a targeted field push so re-aiming the camera never re-transmits the panel’s geometry — important for large voxel/scatter panels.
- reset_view()[source]#
Restore the camera to the angles/zoom set at construction time.
- Return type:
None
- set_xlabel(label, fontsize=None)[source]#
Set the x-axis label (mini-TeX allowed; default size 11 px).
- set_ylabel(label, fontsize=None)[source]#
Set the y-axis label (mini-TeX allowed; default size 11 px).
- set_zlabel(label, fontsize=None)[source]#
Set the z-axis label (mini-TeX allowed; default size 11 px).
- set_data(x, y, z)[source]#
Replace the geometry data (same shape rules as the constructor).
Bounds given at construction time (
bounds=) are preserved.- Return type:
None
- set_point_colors(colors)[source]#
Set (or clear) per-point colours on a scatter or voxels panel.
- Parameters:
colors (list of "#rrggbb" strings, (N, 3) array, or None) – One colour per point / voxel. Floats are interpreted as 0–1 (or 0–255 when the max exceeds 1).
Nonereverts to the singlecolorfor all elements.- Return type:
None
- set_highlight(x, y, z, *, color='#ff1744', size=7.0)[source]#
Mark one 3-D point with an emphasised dot drawn on top.
The highlight is independent of the panel’s geometry — use it to flag the “current” item in a point cloud or on a surface (e.g. the orientation under a crosshair in an IPF explorer). Points on the far side of the data are drawn semi-transparent as a depth cue.
- Parameters:
- Return type:
None
See also
clear_highlightRemove the highlight.
- clear_highlight()[source]#
Remove the highlight point set by
set_highlight().- Return type:
None
- set_sphere(radius=1.0, *, color='#9e9e9e', alpha=0.15, wireframe=True)[source]#
Draw an origin-centred reference sphere behind the data.
Rendered as a shaded silhouette disk plus latitude/longitude wireframe arcs (far-side arcs dimmed). Scatter points on the far side of the sphere are also dimmed, so a point cloud on the sphere reads with correct depth — ideal for inverse-pole-figure / orientation plots of unit vectors.
Assumes origin-centred, isotropic bounds — pass
bounds=((-r, r),) * 3to the constructor so the sphere’s screen silhouette is a true circle.- Parameters:
radius (float, optional) – Sphere radius in data units. Default 1 (unit sphere).
color (str, optional) – Base CSS colour of the shading and wireframe. Default grey.
alpha (float, optional) – Opacity of the shaded silhouette (0–1). Default 0.15.
wireframe (bool, optional) – Draw latitude/longitude arcs. Default True.
- Return type:
None
See also
clear_sphereRemove the reference sphere.
- clear_sphere()[source]#
Remove the reference sphere set by
set_sphere().- Return type:
None