From 82347e77a8879fd56f70b2df0cf6308f1d2fd7f3 Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Fri, 31 Jul 2026 12:55:55 +0200 Subject: [PATCH 1/2] rename mpl figures to something more accurate --- src/plopp/backends/matplotlib/figure.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plopp/backends/matplotlib/figure.py b/src/plopp/backends/matplotlib/figure.py index 660787bf..c34dda5b 100644 --- a/src/plopp/backends/matplotlib/figure.py +++ b/src/plopp/backends/matplotlib/figure.py @@ -3,7 +3,7 @@ from __future__ import annotations from matplotlib.axes import Axes -from matplotlib.figure import Figure as MplFigure +from matplotlib.figure import Figure as MplFig from ...graphics import BaseFig from .canvas import Canvas @@ -28,7 +28,7 @@ def __init_figure__(self, View, *args, **kwargs): self._kwargs = kwargs @property - def fig(self) -> MplFigure: + def fig(self) -> MplFig: """ Get the underlying Matplotlib figure. """ @@ -125,7 +125,7 @@ def get_repr_maker(form=None, npoints=0): return REPR_MAP[form.lower()] -class InteractiveFigure(MplBaseFig, VBox): +class WidgetFigure(MplBaseFig, VBox): """ Create an interactive Matplotlib figure. """ @@ -185,9 +185,9 @@ def linked_home(): toolbar['home'].callback = linked_home -class StaticFigure(MplBaseFig): +class MplFigure(MplBaseFig): """ - Create a static Matplotlib figure. + Create a default Matplotlib figure. The output will be either svg or png, depending on the number of drawn onto the canvas. """ @@ -219,6 +219,6 @@ def to_widget(self): def Figure(*args, **kwargs): if is_widget_backend(): - return InteractiveFigure(*args, **kwargs) + return WidgetFigure(*args, **kwargs) else: - return StaticFigure(*args, **kwargs) + return MplFigure(*args, **kwargs) From c261756be0e9b59c355ca34c5b1a713ad89ecdae Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Fri, 31 Jul 2026 13:32:05 +0200 Subject: [PATCH 2/2] fix test --- tests/backends/matplotlib/mpl_utils_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/backends/matplotlib/mpl_utils_test.py b/tests/backends/matplotlib/mpl_utils_test.py index 06d4122d..adf7da2b 100644 --- a/tests/backends/matplotlib/mpl_utils_test.py +++ b/tests/backends/matplotlib/mpl_utils_test.py @@ -4,7 +4,7 @@ import matplotlib import pytest -from plopp.backends.matplotlib.figure import StaticFigure +from plopp.backends.matplotlib.figure import MplFigure from plopp.backends.matplotlib.utils import is_interactive_backend, is_widget_backend from plopp.data.testing import data_array @@ -35,10 +35,11 @@ def test_static_backends_are_neither_interactive_nor_widget(monkeypatch, backend @pytest.mark.parametrize('backend', ['qtagg', 'tkagg', 'macosx']) -def test_gui_backend_makes_static_figure(monkeypatch, backend): +def test_gui_backend_makes_default_figure(monkeypatch, backend): # GUI backends are used when plotting from a terminal, where ipywidgets-based # interactive figures cannot be displayed. See issue #589. monkeypatch.setattr(matplotlib, 'get_backend', lambda: backend) fig = data_array(ndim=1).plot() - assert isinstance(fig, StaticFigure) + + assert isinstance(fig, MplFigure) assert not fig.interactive