ipympl
ipympl copied to clipboard
set_window_title?
I'd like to change the default file name when saving a figure.
I tried with ax.figure.canvas.set_window_title(new_name)
, but
-
the window title is not correctly changed and
-
the default saving name is always "Figure n".
Can you please tell us what version of mpl, ~what backend~, and what version of Python you are using? Can you also give us a complete, but minimal, example of what you tried that did not work? There is a lot of state associated with GUI windows so the closer we can get to recreating exactly what is going wrong for you the easier it will be to debug.
I failed at reading and thought this was an issues against core Matplotlib :sheep: . in this case the backend you are using is clear from context, but a minimal example is still very helpful.
I tried something very simple:
%matplotlib widget
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.canvas.set_window_title("new name")
With
$ jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.7.3
ipython : 7.18.1
ipykernel : 5.2.1
jupyter client : 6.1.3
jupyter lab : 2.2.2
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.6
traitlets : 4.3.3
$ python --version
Python 3.8.2
$ pip show matplotlib
Name: matplotlib
Version: 3.3.2
Note that it seems that the window title is reset to Figure 1 at the end of the notebook or when the figure is plotted because if I execute again fig.canvas.set_window_title("new name")
(after the first execution of the notebook) the title is correctly changed.
That sounds like there is some state which is getting out of sync and then getting "fixed". Both the Figure and the Manager have a notion of what the name is....