– Start
import numpy as np
import matplotlib.pyplot as plt
# 显示中文标签
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
x = np.array([1, 2, 3, 4])
y = x * 2
# 面向对象编程风格
# 创建图形
fig = plt.figure()
# 添加坐标轴
# 坐标轴位置和大小 (left, bottom, width, height (range 0 to 1))
axes = fig.add_axes([0.1, 0.1, 0.8, 0.8])
axes.plot(x, y, 'b')
axes.set_xlabel('X 轴')
axes.set_ylabel('Y 轴')
axes.set_title('标题')
plt.show()
– 更多参见:Matplotlib 精萃
– 声 明:转载请注明出处
– Last Updated on 2021-01-15
– Written by ShangBo on 2021-01-15
– End