anyplotlib.Plot3D#

class anyplotlib.Plot3D(geom_type, x, y, z, *, colormap='viridis', color='#4fc3f7', 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)[source]#

Bases: object

3-D plot panel.

Supports three geometry types matching matplotlib’s 3-D Axes API:

  • 'surface' – triangulated surface, Z-coloured via colormap.

  • 'scatter' – point cloud, single colour.

  • 'line' – connected line through 3-D points.

Created by Axes.plot_surface(), Axes.scatter3d(), and Axes.plot3d().

Not an anywidget. Holds state in _state dict; every mutation calls _push() which writes to the parent Figure’s panel trait.

Parameters:
to_state_dict()[source]#
Return type:

dict

on_changed(fn)[source]#

Decorator: fires on every rotation/zoom frame.

Parameters:

fn (Callable)

Return type:

Callable

on_release(fn)[source]#

Decorator: fires once when rotation/zoom settles.

Parameters:

fn (Callable)

Return type:

Callable

on_click(fn)[source]#

Decorator: fires on click on this panel.

Parameters:

fn (Callable)

Return type:

Callable

on_key(key_or_fn=None)[source]#

Register a key-press handler for this panel.

Two call forms are supported:

@plot.on_key('q')          # fires only when 'q' is pressed
def handler(event): ...

@plot.on_key               # fires for every registered key
def handler(event): ...

The event carries: key, mouse_x, mouse_y, and last_widget_id.

Note

Registered keys take priority over the built-in r (reset view) shortcut.

Return type:

Callable

disconnect(cid)[source]#

Remove the callback registered under integer cid.

Parameters:

cid (int)

Return type:

None

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 (°).

Parameters:
Return type:

None

set_zoom(zoom)[source]#
Parameters:

zoom (float)

Return type:

None

set_data(x, y, z)[source]#

Replace the geometry data.

Return type:

None