![](/img/trans.png)
[英]How to adjust space between every second row of subplots in matplotlib
[英]How to adjust subplots borders in matplotlib automatically?
當使用plt.subplots
繪制多個圖時,大多數時候子圖之間的間距並不理想,因此頂部 plot 的 xtick 標簽將與底部圖的標題重疊。 有一種方法可以手動解決此問題,方法是調用plt.subplots_adjust(hspace=0.5)
並以交互方式更改參數以獲得外觀不錯的 plot。 有沒有辦法自動計算subplot_adjust
參數? 意思是找到最小的hspace
和wspace
,以便圖的文本之間沒有重疊。
我很確定你會找到最接近內置計算方法的是:
plt.tight_layout() or figure.Figure.tight_layout() #if you are using the object version of the code
You can use tight_layout https://matplotlib.org/stable/tutorials/intermediate/tight_layout_guide.html or constrained_layout https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.