python - 使用熊猫图时如何设置图形标题,而不是斧头标题?
问题描述
使用 pandas 后df.plot
,我想设置整个图的标题,而不是图中的标题,如何实现?
以下两个代码更好地解释了我的问题:
我想在这里添加标题:
lst = [[1, 2], [2, 3], [3, 4]]
plt.figure("I want the title here!")
plt.plot([0, 1, 2], lst)
plt.show()
使用时如何实现这一点df.plot
?
lst = [[1, 2], [2, 3], [3, 4]]
df = pd.DataFrame(lst)
ax = df.plot()
ax.set_title("not the title here")
plt.show()
解决方案
您可以从 中返回一个axis
对象df.plot(**kwargs)
,并用于get_figure()
获取图形对象,然后设置图形标题。
ax = df.plot()
ax.get_figure().canvas.set_window_title('Is this the title you want?')
推荐阅读
- apache - 主机上的 Apache 需要密码,但不接受用户凭据
- python - 是否可以使用 babeltrace Python API(或任何其他软件工具)来读取“实时”LTTng 跟踪?
- angular - 分页 Angular Firestore (FireBase)
- excel - Excel VBA 更改列上的时间/日期格式
- python - python中连接列表和元组的行为不一致
- angular - 如何禁用/启用下拉角4
- tcp - 为什么我们需要 NDS 服务器(不是顶级 DNS)即使我的域在二级
- javascript - 如何在登录 Firebase 时获取用户信息
- r - 这个符号 %<-% 在 r 中有什么用
- xamarin - CATextLayer fontSize 上的 CABasicAnimation 不起作用