22
22
23
23
class NapariMPLWidget (QWidget ):
24
24
"""
25
- Base Matplotlib canvas. Widget that can be embedded as a napari widget .
25
+ Widget containing a Matplotlib canvas and toolbar .
26
26
27
- This creates a single FigureCanvas, which contains a single Figure.
28
- It is not responsible for creating any Axes, because different widgets
29
- may want to implement different subplot layouts.
27
+ This creates a single FigureCanvas, which contains a single
28
+ `~matplotlib.figure.Figure`, and an associated toolbar.
29
+ It is not responsible for creating any Axes, because different
30
+ widgets may want to implement different subplot layouts.
30
31
31
32
This class also handles callbacks to automatically update figures when
32
33
the layer selection or z-step is changed in the napari viewer. To take
@@ -64,12 +65,12 @@ def __init__(
64
65
self .layout ().addWidget (self .toolbar )
65
66
self .layout ().addWidget (self .canvas )
66
67
67
- self .setup_callbacks ()
68
+ self ._setup_callbacks ()
68
69
self .layers : List [napari .layers .Layer ] = []
69
70
70
- # Accept any number of input layers by default
71
+ #: Number of layers taken as input
71
72
n_layers_input = Interval (None , None )
72
- # Accept any type of input layer by default
73
+ #: Type of layer taken as input
73
74
input_layer_types : Tuple [napari .layers .Layer , ...] = (napari .layers .Layer ,)
74
75
75
76
@property
@@ -87,17 +88,17 @@ def n_selected_layers(self) -> int:
87
88
@property
88
89
def current_z (self ) -> int :
89
90
"""
90
- Current z-step of the viewer.
91
+ Current z-step of the napari viewer.
91
92
"""
92
93
return self .viewer .dims .current_step [0 ]
93
94
94
- def setup_callbacks (self ) -> None :
95
+ def _setup_callbacks (self ) -> None :
95
96
"""
96
97
Sets up callbacks.
97
98
98
- Sets up callbacks for:
99
- - Layer selection changing
100
- - z-step changing
99
+ Sets up callbacks for when :
100
+ - Layer selection is changed
101
+ - z-step is changed
101
102
"""
102
103
# z-step changed in viewer
103
104
self .viewer .dims .events .current_step .connect (self ._draw )
@@ -106,7 +107,7 @@ def setup_callbacks(self) -> None:
106
107
107
108
def update_layers (self , event : napari .utils .events .Event ) -> None :
108
109
"""
109
- Update the layers attribute with currently selected layers and re-draw.
110
+ Update the `` layers`` attribute with currently selected layers and re-draw.
110
111
"""
111
112
self .layers = list (self .viewer .layers .selection )
112
113
self ._on_update_layers ()
@@ -149,7 +150,7 @@ def add_single_axes(self) -> None:
149
150
150
151
@staticmethod
151
152
def apply_napari_colorscheme (ax : Axes ) -> None :
152
- """Apply napari-compatible colorscheme to an axes object ."""
153
+ """Apply napari-compatible colorscheme to an Axes ."""
153
154
# changing color of axes background to transparent
154
155
ax .set_facecolor ("none" )
155
156
0 commit comments