获取给定图的标题 [英] Get the title of a given figure

查看:89
本文介绍了获取给定图的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个图形,并在其上附加了一个标题,如下所示:

I have created a figure and have attached to it a title like this:

def func():
    fig = plt.figure()
    fig.suptitle("my title")
    return fig

现在,我想检索在函数中设置的标题.像这样:

Now I would like to retrieve the title I set in the function. Something like this:

fig.get_title()

似乎不存在.除了返回我可以从fig.suptitle("w/e")函数获得的Text对象之外,还有其他想法吗?

It seems not to exist. Any idea besides returning the Text object that I can get from the fig.suptitle("w/e") function ?

推荐答案

似乎没有公共API可以访问它.但请注意,您可以使用非公开/可能不稳定的成员:

There seems to be no public API to access this. But with some cautions you could use the non-public / potentially instable members:

fig._suptitle.get_text()

这篇关于获取给定图的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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