matplotlib.pyplot.subplots_adjust


調整子圖布局,調用格式如下:

subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

參數

 有六個可選參數來控制子圖布局。值均為0~1之間。其中left、bottom、right、top圍成的區域就是子圖的區域。wspace、hspace分別表示子圖之間左右、上下的間距。實際的默認值由matplotlibrc文件控制的。

簡單示例

import matplotlib.pyplot as plt
 
x=[1,2,3]
y=[4,5,6]
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x,y)
axs[0, 1].plot(x,y)
axs[1, 0].plot(x,y)
axs[1, 1].plot(x,y)
 
plt.subplots_adjust(left=0.1, bottom=0.5, right=0.8, wspace=0.01)
 
plt.show()

運行結果如下:

 


免責聲明!

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



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