ipympl icon indicating copy to clipboard operation
ipympl copied to clipboard

set_window_title?

Open paugier opened this issue 4 years ago • 5 comments

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

  1. the window title is not correctly changed and

  2. the default saving name is always "Figure n".

paugier avatar Sep 26 '20 18:09 paugier

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.

tacaswell avatar Sep 26 '20 18:09 tacaswell

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.

tacaswell avatar Sep 26 '20 18:09 tacaswell

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

paugier avatar Sep 26 '20 20:09 paugier

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.

paugier avatar Sep 26 '20 20:09 paugier

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....

tacaswell avatar Sep 29 '20 21:09 tacaswell