Skip to content

Use set_window_title rather than set_label to set title of webagg figure #29338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/behavior/29256_IMT.rst
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 2 additions & 4 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,8 @@
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())

Check warning on line 332 in lib/matplotlib/backends/backend_webagg_core.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backends/backend_webagg_core.py#L332

Added line #L332 was not covered by tests
self._force_full = True
if self.toolbar:
# Normal toolbar init would refresh this, but it happens before the
Expand Down
Loading