python-3.x - how to Change matplotlib.figure.Figure objects axis names
问题描述
I have matplotlib.figure.Figure object named as fig1 and which contains
>>> fig1
Now that I wants to change Y ( axis secondary) name from
Bad probability
to
Event probability
I also wants to change title from
Hour
to
Hours to Event
but i could not find how to achive that. There are several solution present on stack overflow like
How to set X and Y axis Title in matplotlib.pyplot
but they explains changing plot title while creating graph where as i am having graph object already created and I just wants to change axis names and title
解决方案
As far I can see, I suppose you plot two axes on the same figure with twinx()
.
If you want to change the labels of the last created axis (in your case the line plot) than you can use the gca()
shortcut (Get Current Axes) to set the label as follows:
fig1.gca().set_ylabel("Event probability")
The figure title can be set with:
fig1.suptitle("Hours to Event")
推荐阅读
- active-directory - WSO2 身份服务器无法管理 Active Directory 用户
- python - django.core.exceptions.ImproperlyConfigured,在 url 中找不到循环导入或问题
- django - 与切换按钮交互后更新数据库值。Django/HTML
- python - 在 sklearn GradientBoostingRegressor 中指定 Huber loss epsilon 参数
- php - Eloquent whereIn error:1390 Prepared statement contains too many placeholders laravel 5.7
- wordpress - 503 服务不可用 - EC-2 / WordPress 与 NGINX 和 SSL 经 Bitnami-4-9-8-1-r40 认证
- c++ - C++ equation returns -nan(ind)
- server - 从网络服务器连接到 SFTP 服务器/防火墙问题
- jenkins - 从 jenkins 执行 behat 命令时遇到一些问题(执行 shell)
- python - 安装 Tensorflow 问题:pip 没有升级