Skip to content

Commit

Permalink
Core: Add matplotlib backend name for lab 4
Browse files Browse the repository at this point in the history
In lab 4 the `ipympl.backend_nbagg` backend is called `widget`.
  • Loading branch information
agoscinski committed Jul 3, 2024
1 parent 6c48f43 commit dd5767a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/scwidgets/cue/_widget_cue_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ def __init__(
# we close the figure so the figure is only contained in this widget
# and not shown using plt.show()
plt.close(self.figure)
elif matplotlib.backends.backend == "module://ipympl.backend_nbagg":
elif (
matplotlib.backends.backend == "module://ipympl.backend_nbagg"
or matplotlib.backends.backend == "widget"
):
# jupyter lab 3 uses "module://ipympl.backend_nbagg"
# jupyter lab 4 uses "widget"
with self:
self.figure.canvas.show()
else:
Expand All @@ -83,7 +88,12 @@ def clear_display(self, wait=False):
if matplotlib.backends.backend == "module://matplotlib_inline.backend_inline":
self.clear_figure()
self.clear_output(wait=wait)
elif matplotlib.backends.backend == "module://ipympl.backend_nbagg":
elif (
matplotlib.backends.backend == "module://ipympl.backend_nbagg"
or matplotlib.backends.backend == "widget"
):
# jupyter lab 3 uses "module://ipympl.backend_nbagg"
# jupyter lab 4 uses "widget"
self.clear_figure()
if not (wait):
self.figure.canvas.draw_idle()
Expand All @@ -100,7 +110,12 @@ def draw_display(self):
if matplotlib.backends.backend == "module://matplotlib_inline.backend_inline":
with self:
display(self.figure)
elif matplotlib.backends.backend == "module://ipympl.backend_nbagg":
elif (
matplotlib.backends.backend == "module://ipympl.backend_nbagg"
or matplotlib.backends.backend == "widget"
):
# jupyter lab 3 uses "module://ipympl.backend_nbagg"
# jupyter lab 4 uses "widget"
self.figure.canvas.draw_idle()
self.figure.canvas.flush_events()
else:
Expand Down

0 comments on commit dd5767a

Please sign in to comment.