From 767979e3249e19132e0f922445178ff90a19ea24 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Tue, 17 Dec 2024 17:30:36 +0000 Subject: [PATCH] Use set_window_title rather than set_label to set title of webagg figure --- doc/api/next_api_changes/behavior/29256_IMT.rst | 6 ++++++ lib/matplotlib/backends/backend_webagg_core.py | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 doc/api/next_api_changes/behavior/29256_IMT.rst diff --git a/doc/api/next_api_changes/behavior/29256_IMT.rst b/doc/api/next_api_changes/behavior/29256_IMT.rst new file mode 100644 index 000000000000..57ec8f68d85c --- /dev/null +++ b/doc/api/next_api_changes/behavior/29256_IMT.rst @@ -0,0 +1,6 @@ +Setting titles of figures using webagg backend +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Previously when using the ``webagg`` backend the title of a figure was set using +``figure.set_label``. Now it is set using ``figure.canvas.manager.set_window_title`` +which is more consistent with other backends. diff --git a/lib/matplotlib/backends/backend_webagg_core.py b/lib/matplotlib/backends/backend_webagg_core.py index 12906827a466..33490ff66dc5 100644 --- a/lib/matplotlib/backends/backend_webagg_core.py +++ b/lib/matplotlib/backends/backend_webagg_core.py @@ -328,10 +328,8 @@ def handle_toolbar_button(self, event): getattr(self.toolbar, event['name'])() def handle_refresh(self, event): - figure_label = self.figure.get_label() - if not figure_label: - figure_label = f"Figure {self.manager.num}" - self.send_event('figure_label', label=figure_label) + if self.manager: + self.send_event('figure_label', label=self.manager.get_window_title()) self._force_full = True if self.toolbar: # Normal toolbar init would refresh this, but it happens before the