NapariMPLWidget#

class napari_matplotlib.base.NapariMPLWidget(napari_viewer: napari.Viewer, parent: QWidget | None = None)#

Bases: BaseNapariMPLWidget

Widget containing a Matplotlib canvas and toolbar.

In addition to BaseNapariMPLWidget, this class handles callbacks to automatically update figures when the layer selection or z-step is changed in the napari viewer. To take advantage of this sub-classes should implement the clear() and draw() methods.

When both the z-step and layer selection is changed, clear() is called and if the number a type of selected layers are valid for the widget draw() is then called. When layer selection is changed on_update_layers() is also called, which can be useful e.g. for updating a layer list in a selection widget.

See also

BaseNapariMPLWidget

The parent class of this widget. Contains helpful methods for creating and working with the Matplotlib figure and any axes.

Attributes:
viewernapari.Viewer

Main napari viewer.

layerslist

List of currently selected napari layers.

Attributes Summary

current_z

Current z-step of the napari viewer.

input_layer_types

Type of layer taken as input

n_layers_input

Number of layers taken as input

n_selected_layers

Number of currently selected layers.

Methods Summary

clear()

Clear any previously drawn figures.

draw()

Re-draw any figures.

on_update_layers()

Called when the selected layers are updated.

Attributes Documentation

current_z#

Current z-step of the napari viewer.

input_layer_types: tuple[Layer, ...] = (<class 'napari.layers.base.base.Layer'>,)#

Type of layer taken as input

n_layers_input = Interval(None, None)#

Number of layers taken as input

n_selected_layers#

Number of currently selected layers.

Methods Documentation

clear() None#

Clear any previously drawn figures.

This is a no-op, and is intended for derived classes to override.

draw() None#

Re-draw any figures.

This is a no-op, and is intended for derived classes to override.

on_update_layers() None#

Called when the selected layers are updated.

This is a no-op, and is intended for derived classes to override.