Skip to content

Add SingleAxesWidget class #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/napari_matplotlib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class NapariMPLWidget(QWidget):
Base widget that can be embedded as a napari widget and contains a
Matplotlib canvas.

This creates a single Axes, and sub-classes should implement logic for
drawing on that Axes.
This creates a single Figure, and sub-classes should implement logic for
drawing on that Figure.

Attributes
----------
Expand All @@ -34,8 +34,6 @@ class NapariMPLWidget(QWidget):
Matplotlib figure.
canvas : matplotlib.backends.backend_qt5agg.FigureCanvas
Matplotlib canvas.
axes : `matplotlib.axes.Axes`
Matplotlib axes.
"""

def __init__(self, napari_viewer: napari.viewer.Viewer):
Expand All @@ -46,7 +44,6 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
self.canvas = FigureCanvas()
self.canvas.figure.patch.set_facecolor("#262930")
self.toolbar = NavigationToolbar2QT(self.canvas, self)
self.axes = self.canvas.figure.subplots()

self.setLayout(QVBoxLayout())
self.layout().addWidget(self.toolbar)
Expand Down
1 change: 1 addition & 0 deletions src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HistogramWidget(NapariMPLWidget):

def __init__(self, napari_viewer: napari.viewer.Viewer):
super().__init__(napari_viewer)
self.axes = self.canvas.figure.subplots()
self.layer = self.viewer.layers[-1]

self.viewer.dims.events.current_step.connect(self.hist_current_layer)
Expand Down
1 change: 1 addition & 0 deletions src/napari_matplotlib/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ScatterWidget(NapariMPLWidget):

def __init__(self, napari_viewer: napari.viewer.Viewer):
super().__init__(napari_viewer)
self.axes = self.canvas.figure.subplots()
self.layers = self.viewer.layers[-2:]

self.viewer.dims.events.current_step.connect(
Expand Down