Fix Python – Change figure window title in pylab

Question

Asked By – Omar

How can I set a figure window’s title in pylab/python?

fig = figure(9) # 9 is now the title of the window
fig.set_title("Test") #doesn't work
fig.title = "Test" #doesn't work

Now we will see solution for issue: Change figure window title in pylab


Answer

If you want to actually change the window you can do:

fig = pylab.gcf()
fig.canvas.set_window_title('Test')

Update 2021-05-15:

The solution above is deprecated (see here). instead use

fig = pylab.gcf()
fig.canvas.manager.set_window_title('Test')

This question is answered By – Andrew Walker

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0