Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/plopp/backends/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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)
7 changes: 4 additions & 3 deletions tests/backends/matplotlib/mpl_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Loading