matplotlib和子图属性

matplotlib和子图属性,第1张

matplotlib和子图属性

plt.subplot
返回子图对象,该对象是轴对象的类型。它有两种添加轴标签的方法:
set_xlabel
set_ylabel

ax = plt.subplot('111')ax.set_xlabel('X Axis')ax.set_ylabel('Y Axis')

您还可以调用

plt.xlabel
plt.ylabel
(像以前一样)并指定要应用标签的轴。

ax = plt.subplot('111')plt.xlabel('X Axis', axes=ax)plt.ylabel('Y Axis', axes=ax)

由于只有一个轴,因此也可以省略

axes
kwarg,因为如果未指定一个轴,标签将自动应用于当前轴

ax = plt.subplot('111')plt.xlabel('X Axis')plt.ylabel('Y Axis')


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5617182.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存