plt繪制子圖


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)

image-20211102151041377

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')

image-20211102151136377


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM