App下載

python怎么調(diào)整圖與圖之間的間距?matplotlib使用介紹!

猿友 2021-07-21 14:52:30 瀏覽數(shù) (8420)
反饋

在使用matplotlib繪制多個圖的時候,圖與圖之間的的間隔可能并不是我們想要的,間隔過大或者過小都會影響頁面的美觀性,也不好做數(shù)據(jù)的比對。那么python圖與圖間距調(diào)整要怎么操作呢,實際上要用到matplotlib的subplots_adjust參數(shù)。接下來我們就來看看怎么操作吧。

如下所示:

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

圖與圖之間的間距調(diào)整

wspace=0.15,hspace=0.15

圖間距調(diào)整

補充:python如何調(diào)整subplot的間距

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots_adjust.html

plt.subplots_adjust(left=None, bottom=None, right=None, top=None,
                wspace=None, hspace=None)
left  = 0.125  # the left side of the subplots of the figure
right = 0.9    # the right side of the subplots of the figure
bottom = 0.1   # the bottom of the subplots of the figure
top = 0.9      # the top of the subplots of the figure
wspace = 0.2   # the amount of width reserved for blank space between subplots,
               # expressed as a fraction of the average axis width
hspace = 0.2   # the amount of height reserved for white space between subplots,
               # expressed as a fraction of the average axis height

以上就是matplotlib調(diào)整圖間距的方法了,希望能給大家一個參考,也希望大家多多支持W3Cschool。

0 人點贊