plt绘制子图

plt.subplot(221)

# equivalent but more general
# 子图1
ax1 = plt.subplot(2, 2, 1)

# add a subplot with no frame
# 子图2
ax2 = plt.subplot(222, frameon=False)

# add a polar subplot
# 子图3
plt.subplot(223, projection='polar')

# add a red subplot that shares the x-axis with ax1
# 子图4
plt.subplot(224, sharex=ax1, facecolor='red')

删除一个子图。

plt.subplot(221)

# equivalent but more general
ax1 = plt.subplot(2, 2, 1)

# add a subplot with no frame
ax2 = plt.subplot(222, frameon=False)

# add a polar subplot
plt.subplot(223, projection='polar')

# add a red subplot that shares the x-axis with ax1
plt.subplot(224, sharex=ax1, facecolor='red')

# delete ax2 from the figure
plt.delaxes(ax2)

plt绘制子图

x = [1,2,3]
y1 = x
y2 = [4,5,6]
y3 = [7,8,9]
y4 = [12,9,11]

ax1 = plt.subplot(221)
ax1.margins(0.05)
ax1.plot(x,y1)
# 标题
ax1.set_title('1',loc='left')

ax2 = plt.subplot(222)
ax2.margins(0.05)
ax2.plot(x,y2)
# 标题
ax2.set_title('2')

ax3 = plt.subplot(223)
ax3.margins(0.05)
ax3.plot(x,y3)
# 标题
ax3.set_title('3')

ax4 = plt.subplot(224)
ax4.margins(0.05)
ax4.plot(x,y3)
# 标题
ax4.set_title('4')

plt绘制子图

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2021-07-09
  • 2021-08-18
  • 2022-12-23
  • 2021-10-27
  • 2021-09-25
猜你喜欢
  • 2021-10-18
  • 2021-06-24
  • 2021-11-27
  • 2022-01-06
  • 2021-08-10
  • 2022-12-23
  • 2021-08-19
相关资源
相似解决方案