App下載

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

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

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

如下所示:

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

補(bǔ)充: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)整圖間距的方法了,希望能給大家一個(gè)參考,也希望大家多多支持W3Cschool。

0 人點(diǎn)贊