import matplotlib.pyplot as plt
# 1. 创建图像
# 1.1 创建一个简单的线性图像
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
# 1.2 创建多个图像并显示
fig, axs = plt.subplots(nrows=2, ncols=3)
for i in range(6):
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x) + np.cos(i*np.pi/4)*0.5
axs[i//3, i%3].plot(x, y)
# 2. 修改图像
# 2.1 标题和副标题
plt.title('Title')
plt.subtitle('Subtitle')
# 2.2 刻度线
plt.xlabel('X Label')
plt.ylabel('Y Label')
# 3. 多维图像
# 3.1 创建一个三维数组
X, Y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))
Z = np.sin(X) + np.cos(Y)
# 3.2 创建三维图像
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(X, Y, Z)
# 4. 其他功能
# 4.1 保存图像
plt.savefig('image.png')
# 4.2 显示帮助文档
help(plt.plot)