设置matplotlib默认图形窗口标题 [英] Set matplotlib default figure window title

查看:175
本文介绍了设置matplotlib默认图形窗口标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图形的默认窗口标题是图形X,其中每个图形X都增加.

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')

但是如何更改默认的窗口标题(以使其成为Test 1,Test 2等)?这样我就不需要每次都更改窗口标题.我在mpl.rcParams中找不到键

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

谢谢

推荐答案

使用 matplotlib.pyplot.subplots 创建图形时,有一个可选参数 num ,即使没有记录下来(据我所能搜索),后来也被用作图标题:

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.

(警告:即使未记录,此 num 值也是该数字的关键.因此,请注意不要重复使用相同的值.)

(Caution: even if not documented, this num value is also a key to this figure. So, take care not to reuse the same value.)

结果如下:

这篇关于设置matplotlib默认图形窗口标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆