The default window title of a figure is figure X, where X is increased each figure.
I know how to change the title of a figure:
fig = pylab.gcf()
fig.canvas.set_window_title('Test')
But how do I change the default window title (So that it will be Test 1, Test 2 etc..)? so that I will not need to change the window title each time. I did not find a key in the mpl.rcParams
Thanks
Edit: my answer does not change the defaults, as requested by OP, but provides a way to define figure title at figure creation.
When creating a figure using matplotlib.pyplot.subplots
, there is an optional argument num
that, even if not documented as such (as far as I could search), is later used as figure title:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, num="some nice window title")
plt.ion() # to make plot non-blocking, i.e. if multiple plots are launched
fig.show()
It is also used as default filename when saving the plot, which is a very neat feature.
(Caution: even if not documented, this num
value is also a key to this figure. So, take care not to reuse the same value.)
And here's the result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With