# step1 准备数据
x = np.linspace(0, 2, 100)
y = x**2
# step2 第五章:设置绘图样式(非必须)
mpl.rc('lines', winewidth=4, linestyle='-.')
# step3 第三章:定义布局
fig, ax = plt.subplots()
# step4 第二章:绘制图像
ax.plot(x, y, label="linear")
# step5 第四章:标签,文字和图例
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title("Simple Plot")
ax.legend()
plt.show()
# step1 准备数据
x = np.linspace(0, 2, 100)
y = x**2
# step2 第五章:设置绘图样式(非必须)
mpl.rc('lines', winewidth=4, linestyle='-.')
# step3 第二章:绘制图像
plt.plot(x, y, label="linear")
# step4 第五章:标签,文字和图例
plt.xlabel('x label')
plt.ylabel('y label')
plt.title('Simple Plot')
plt.legend()
plt.show()
手机扫一扫
移动阅读更方便
你可能感兴趣的文章