![25bd872893d525be3eef175c36d91618.png](https://img-blog.csdnimg.cn/img_convert/25bd872893d525be3eef175c36d91618.png)
绘制方法 <1>
本文将通过最简单的模式拆解Matplotlib绘图的几个组成部分,将cover以下内容
1. Create a dataset
2. Create a canvas
3. Add data to canvas
4. Show the figure
import numpy as np
import matplotlib.pyplot as plt
# create a dataset
points = np.linspace(-5, 5, 256)
y1 = np.tanh(points) + 0.5
y2 = np.sin(points) - 0.2
# create a canvas
fig, axe = plt.subplots(figsize=(7, 3.5), dpi=300)
# add data to canvas
axe.plot(points, y1)
axe.plot(points, y2)
# show the figure
fig.savefig('output/to.png')
plt.close(fig)