Skip to content

Commit edf6539

Browse files
authored
Merge pull request #221 from dstansby/mpl38
Remove Matplotlib pin
2 parents c4c38c6 + f253247 commit edf6539

12 files changed

+11
-13
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ project_urls =
2727
[options]
2828
packages = find:
2929
install_requires =
30-
matplotlib<3.8
30+
matplotlib
3131
napari
3232
numpy
3333
tinycss2

src/napari_matplotlib/base.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import matplotlib
66
import matplotlib.style as mplstyle
77
import napari
8-
from matplotlib.backends.backend_qtagg import (
9-
FigureCanvas,
8+
from matplotlib.backends.backend_qtagg import ( # type: ignore[attr-defined]
9+
FigureCanvasQTAgg,
1010
NavigationToolbar2QT,
1111
)
1212
from matplotlib.figure import Figure
@@ -49,12 +49,10 @@ def __init__(
4949

5050
# Sets figure.* style
5151
with mplstyle.context(self.mpl_style_sheet_path):
52-
self.canvas = FigureCanvas()
52+
self.canvas = FigureCanvasQTAgg() # type: ignore[no-untyped-call]
5353

5454
self.canvas.figure.set_layout_engine("constrained")
55-
self.toolbar = NapariNavigationToolbar(
56-
self.canvas, parent=self
57-
) # type: ignore[no-untyped-call]
55+
self.toolbar = NapariNavigationToolbar(self.canvas, parent=self)
5856
self._replace_toolbar_icons()
5957
# callback to update when napari theme changed
6058
# TODO: this isn't working completely (see issue #140)
@@ -97,7 +95,7 @@ def add_single_axes(self) -> None:
9795
# Sets axes.* style.
9896
# Does not set any text styling set by axes.* keys
9997
with mplstyle.context(self.mpl_style_sheet_path):
100-
self.axes = self.figure.subplots()
98+
self.axes = self.figure.add_subplot()
10199

102100
def _on_napari_theme_changed(self) -> None:
103101
"""
@@ -260,7 +258,7 @@ def _draw(self) -> None:
260258
isinstance(layer, self.input_layer_types) for layer in self.layers
261259
):
262260
self.draw()
263-
self.canvas.draw()
261+
self.canvas.draw() # type: ignore[no-untyped-call]
264262

265263
def clear(self) -> None:
266264
"""
@@ -309,8 +307,8 @@ def clear(self) -> None:
309307
class NapariNavigationToolbar(NavigationToolbar2QT):
310308
"""Custom Toolbar style for Napari."""
311309

312-
def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def]
313-
super().__init__(*args, **kwargs)
310+
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def]
311+
super().__init__(*args, **kwargs) # type: ignore[no-untyped-call]
314312
self.setIconSize(
315313
from_napari_css_get_size_of(
316314
"QtViewerPushButton", fallback=(28, 28)
@@ -319,7 +317,7 @@ def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def]
319317

320318
def _update_buttons_checked(self) -> None:
321319
"""Update toggle tool icons when selected/unselected."""
322-
super()._update_buttons_checked()
320+
super()._update_buttons_checked() # type: ignore[no-untyped-call]
323321
icon_dir = self.parentWidget()._get_path_to_icon()
324322

325323
# changes pan/zoom icons depending on state (checked or not)
Loading
Loading
Loading
Loading
Loading

src/napari_matplotlib/tests/test_theme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,6 @@ def test_custom_stylesheet(make_napari_viewer, image_data):
187187
assert widget.figure.patch.get_facecolor() == to_rgba("#fdf6e3")
188188
for gridline in ax.get_xgridlines() + ax.get_ygridlines():
189189
assert gridline.get_visible() is True
190-
assert gridline.get_color() == "#fdf6e3"
190+
assert gridline.get_color() == "#b0b0b0"
191191
finally:
192192
os.remove(style_sheet_path)

0 commit comments

Comments
 (0)