Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77470b5

Browse filesBrowse files
committed
Clean up basewidget docs/api
1 parent 8cef781 commit 77470b5
Copy full SHA for 77470b5

File tree

Expand file treeCollapse file tree

1 file changed

+15
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-14
lines changed

‎src/napari_matplotlib/base.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/base.py
+15-14Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
class NapariMPLWidget(QWidget):
2424
"""
25-
Base Matplotlib canvas. Widget that can be embedded as a napari widget.
25+
Widget containing a Matplotlib canvas and toolbar.
2626
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.
3031
3132
This class also handles callbacks to automatically update figures when
3233
the layer selection or z-step is changed in the napari viewer. To take
@@ -60,12 +61,12 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
6061
self.layout().addWidget(self.toolbar)
6162
self.layout().addWidget(self.canvas)
6263

63-
self.setup_callbacks()
64+
self._setup_callbacks()
6465
self.layers: List[napari.layers.Layer] = []
6566

66-
# Accept any number of input layers by default
67+
#: Number of layers taken as input
6768
n_layers_input = Interval(None, None)
68-
# Accept any type of input layer by default
69+
#: Type of layer taken as input
6970
input_layer_types: Tuple[napari.layers.Layer, ...] = (napari.layers.Layer,)
7071

7172
@property
@@ -83,17 +84,17 @@ def n_selected_layers(self) -> int:
8384
@property
8485
def current_z(self) -> int:
8586
"""
86-
Current z-step of the viewer.
87+
Current z-step of the napari viewer.
8788
"""
8889
return self.viewer.dims.current_step[0]
8990

90-
def setup_callbacks(self) -> None:
91+
def _setup_callbacks(self) -> None:
9192
"""
9293
Sets up callbacks.
9394
94-
Sets up callbacks for:
95-
- Layer selection changing
96-
- z-step changing
95+
Sets up callbacks for when:
96+
- Layer selection is changed
97+
- z-step is changed
9798
"""
9899
# z-step changed in viewer
99100
self.viewer.dims.events.current_step.connect(self._draw)
@@ -102,7 +103,7 @@ def setup_callbacks(self) -> None:
102103

103104
def update_layers(self, event: napari.utils.events.Event) -> None:
104105
"""
105-
Update the layers attribute with currently selected layers and re-draw.
106+
Update the ``layers`` attribute with currently selected layers and re-draw.
106107
"""
107108
self.layers = list(self.viewer.layers.selection)
108109
self._on_update_layers()
@@ -145,7 +146,7 @@ def add_single_axes(self) -> None:
145146

146147
@staticmethod
147148
def apply_napari_colorscheme(ax: Axes) -> None:
148-
"""Apply napari-compatible colorscheme to an axes object."""
149+
"""Apply napari-compatible colorscheme to an Axes."""
149150
# changing color of axes background to transparent
150151
ax.set_facecolor("none")
151152

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.