import matplotlib.pyplot as plt
fig = plt.figure() # 先创建一个画板
ax1 = fig.add_subplot(221) # 设置i行j列,指定在第k个位置
ax1.set(xlim = [0.5,4.5],ylim = [-2,8]) # 设置x轴、y轴范围
ax1 = fig.add_subplot(222)
ax1.set(xlim = [0.5,4.5],ylim = [-2,8])
ax1 = fig.add_subplot(224)
ax1.set(xlim = [0.5,4.5],ylim = [-2,8])
plt.show()
import matplotlib.pyplot as plt
fig = plt.figure() # 先创建一个画板
ax = fig.add_subplot(111)
#设置x轴、y轴的范围,标题,x轴、y轴标签
ax.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes',
ylabel='Y-Axis', xlabel='X-Axis')
plt.show()