Skip to content

Commit 23d7531

Browse files
committed
Fix compatability
1 parent 342f727 commit 23d7531

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/napari_matplotlib/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def setup_callbacks(self) -> None:
8383

8484
def update_layers(self, event: napari.utils.events.Event) -> None:
8585
"""
86-
Update the currently selected layers and re-draw.
86+
Update the layers attribute with currently selected layers and re-draw.
8787
"""
8888
self.layers = list(self.viewer.layers.selection)
8989
self._draw()

src/napari_matplotlib/slice.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
from qtpy.QtWidgets import QComboBox, QHBoxLayout, QSpinBox
66

7-
from napari_matplotlib.base import SingleLayerWidget
7+
from napari_matplotlib.base import NapariMPLWidget
88

99
__all__ = ["SliceWidget"]
1010

@@ -15,6 +15,7 @@ class SliceWidget(NapariMPLWidget):
1515
"""
1616
Plot a 1D slice along a given dimension.
1717
"""
18+
1819
n_layers_input = 1
1920

2021
def __init__(self, napari_viewer: napari.viewer.Viewer):
@@ -33,8 +34,11 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
3334
self.slice_selectors[d] = QSpinBox()
3435
button_layout.addWidget(self.slice_selectors[d])
3536

36-
self.update_slice_selectors()
37-
self.draw()
37+
self.update_layers(None)
38+
39+
@property
40+
def layer(self):
41+
return self.layers[0]
3842

3943
@property
4044
def current_dim(self) -> str:
@@ -88,10 +92,14 @@ def get_xy(self) -> Tuple[np.ndarray, np.ndarray]:
8892

8993
return x, y
9094

95+
def clear(self) -> None:
96+
self.axes.cla()
97+
9198
def draw(self) -> None:
9299
"""
93100
Clear axes and draw a 1D plot.
94101
"""
102+
self.update_slice_selectors()
95103
x, y = self.get_xy()
96104

97105
self.axes.plot(x, y)

0 commit comments

Comments
 (0)