Changing matplotlib window title is throwing strange error
Question:
I’m using python 3.6 in Jupyter lab on a linux mint machine to run this snippet of code
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.window.setWindowTitle("New Title")
..it returns the following error message:
AttributeError: 'FigureManagerBase' object has no attribute 'window'
I have checked the GUI backends. All are available and all of them return this error even if I force the backend using …
import matplotlib
matplotlib.use(<gui>,warn=False, force=True)
…before importing pyplot. The code has been working OK in Spyder but I’ve had to move to Jupyter. The matplotlib docs say that FigureManagerBase attributes include ‘window’. I’m stumped
Answers:
To change the window title, use the code below:
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.canvas.set_window_title("New Title")
Using python 3.8, matplotlib 3.5.3 the following works for me:
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.set_window_title("New Title")
I’m using python 3.6 in Jupyter lab on a linux mint machine to run this snippet of code
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.window.setWindowTitle("New Title")
..it returns the following error message:
AttributeError: 'FigureManagerBase' object has no attribute 'window'
I have checked the GUI backends. All are available and all of them return this error even if I force the backend using …
import matplotlib
matplotlib.use(<gui>,warn=False, force=True)
…before importing pyplot. The code has been working OK in Spyder but I’ve had to move to Jupyter. The matplotlib docs say that FigureManagerBase attributes include ‘window’. I’m stumped
To change the window title, use the code below:
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.canvas.set_window_title("New Title")
Using python 3.8, matplotlib 3.5.3 the following works for me:
import matplotlib.pyplot as plt
fig = plt.figure()
man = plt.get_current_fig_manager()
man.set_window_title("New Title")