Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Use set_window_title rather than set_label to set title of webagg figure#29338
Uh oh!
There was an error while loading.Please reload this page.
Conversation
What's the behavior with respect to the label? I assume the label is used as a fallback if the window title is not set? If that's correct, the behavoir should be documented, with the comment that it results in backward compatibility for previous users of |
Unfortunately it is not that simple. If the window matplotlib/lib/matplotlib/backend_bases.py Line 2612 inf2717a5
regardless of the backend used. This can be overridden by passing a To demonstrate this use importmatplotlibasmplmpl.use("qtagg")#mpl.use('webagg')importmatplotlib.pyplotasplt# 1. Set title using set_window_titlefig1,ax1=plt.subplots(figsize=(3,2))fig1.canvas.manager.set_window_title('Using set_window_title')# 2. Set title using label passed to Figure constructorfig2,ax2=plt.subplots(figsize=(3,2),label="Label in constructor")# 3. Using Figure.set_label has no effect on the window titlefig3,ax3=plt.subplots(figsize=(3,2))fig3.set_label("This is not used in the title")plt.show() and the title outputs are the same for So this PR brings |
02263ba
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
Closes#29256.
Previously when using the
webagg
backend if you wanted to change the title above a figure you would usefigure.set_label('whatever')
and if you usedfigure.canvas.manager.set_window_title('whatever')
it would be ignored. This was inconsistent with other backends which use the latter.This PR changes the behaviour so that
figure.canvas.manager.set_window_title('whatever')
is used now forwebagg
, the same as the other backends.There is no test as there isn't currently any visual testing of the
webagg
backend. There is some draft work underway in#23540 for this. So here is a demonstration instead, using this code:the
webagg
output is:which is consistent with the output produced by e.g. the
qtagg
backend:PR checklist
WebAgg
backend #29256" is in the body of the PR description tolink the related issue