学习代码:
import matplotlib.pyplot as plt
import numpy as np
# fig, ax = plt.subplots() # 创建一个包含一个axes的figure
# ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # 绘制图像
# plt.show()
fig = plt.figure() # an empty figure with no Axes
fig, ax = plt.subplots() # a figure with a single Axes
fig, axs = plt.subplots(2, 2) # a figure with a 2x2 grid of Axes
# line =plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
# plt.show()
x = np.linspace(0, 2, 100)
fig, ax = plt.subplots()
ax.plot(x, x, label='linear')
ax.plot(x, x**2, label='quadratic')
ax.plot(x, x**3, label='cubic')
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title("Simple Plot")
ax.legend()
plt.show()
x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("Simple Plot")
plt.legend()
plt.show()
学习了Figure 图窗、Axes 坐标区、Axis 坐标轴、Subplot 子图。
明天继续加油!



