python Matplotlib 绘制多个子图

from matplotlib import pyplot as plt
import numpy as np

a = np.arange(1, 30)
# 划分子图
fig, axs = plt.subplots(2, 2)
# 绘制子图
axs1 = axs[0, 0]
axs2 = axs[0, 1]
axs3 = axs[1, 0]
axs4 = axs[1, 1]
axs1.plot(a, a)
axs2.plot(a, np.sin(a))
axs3.plot(a, np.log(a))
axs4.plot(a, a ** 2)
plt.show()

python Matplotlib 绘制多个子图_第1张图片

 

你可能感兴趣的:(笔记,python)