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
2 changes: 1 addition & 1 deletion src/plopp/backends/matplotlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def make_figure(*args, **kwargs) -> plt.Figure:
if is_interactive_backend():
# Create a manager for the figure, which makes it interactive, as well as
# making it possible to show the figure from the terminal.
plt._backend_mod.new_figure_manager_given_figure(1, fig)
plt._get_backend_mod().new_figure_manager_given_figure(1, fig)
return fig


Expand Down
16 changes: 15 additions & 1 deletion tests/backends/matplotlib/mpl_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

import matplotlib
import matplotlib.pyplot as plt
import pytest

from plopp.backends.matplotlib.figure import StaticFigure
from plopp.backends.matplotlib.utils import is_interactive_backend, is_widget_backend
from plopp.backends.matplotlib.utils import (
is_interactive_backend,
is_widget_backend,
make_figure,
)
from plopp.data.testing import data_array


Expand Down Expand Up @@ -34,6 +39,15 @@ def test_static_backends_are_neither_interactive_nor_widget(monkeypatch, backend
assert not is_widget_backend()


@pytest.mark.usefixtures('_use_ipympl')
def test_make_figure_initializes_pyplot_backend(monkeypatch):
monkeypatch.setattr(plt, '_backend_mod', None)

fig = make_figure()

assert fig.canvas.manager is not None


@pytest.mark.parametrize('backend', ['qtagg', 'tkagg', 'macosx'])
def test_gui_backend_makes_static_figure(monkeypatch, backend):
# GUI backends are used when plotting from a terminal, where ipywidgets-based
Expand Down
Loading