Matplotlib 轴对象究竟是什么?


Axes 类包含大部分图形元素 − 轴、刻度、Line2D、文本、多边形等,并设置坐标系。

步骤

  • 设置图形大小,调整子图之间的间距和周围的填充。

  • 使用 rcParams 设置轴线宽。

  • 向当前图形添加轴并使其成为当前轴。

  • 设置轴主干颜色。

  • 若要显示图形,使用 show() 方法。

示例

from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
plt.rcParams['axes.linewidth'] = 5

ax = plt.axes()

ax.spines['bottom'].set_color('yellow')
ax.spines['top'].set_color('red')
ax.spines['right'].set_color('black')
ax.spines['left'].set_color('blue')

plt.show()

输出

更新于: 10-Aug-2021

277 次浏览

开启你的 职业生涯

通过完成课程获得认证

入门
广告
© . All rights reserved.