Python中subplots_adjust函數(shù)的用法
Python中subplots_adjust函數(shù)
subplots_adjust(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
參數(shù)含義
left, right, bottom, top:子圖所在區(qū)域的邊界。
當值大于1.0的時候子圖會超出figure的邊界從而顯示不全;值不大于1.0的時候,子圖會自動分布在一個矩形區(qū)域(下圖灰色部分)。
要保證left < right, bottom < top,否則會報錯。
使用subplots_adjust一般會傳入6個參數(shù),我們分別用A,B,C,D,E,F(xiàn)表示。
然后我們對圖框建立坐標系,將坐標軸原點定在左下角點,并將整個圖框歸一化,即橫縱坐標都是0到1之間。
從下圖中可以看出前四個參數(shù)所代表的距離
A,B可以理解是圖像左下角點的坐標,C,D可以理解為圖像右上角點的坐標,至于E,F則是控制子圖之間的距離。
注意這些值都是0到1之間的值,代表百分比。
python繪圖子圖間距調(diào)整:subplots_adjust
官網(wǎng)注釋:
我是個初學者,個人認為不懂的可以先看看官網(wǎng)的文檔,再去百度什么的,理解別人的代碼。
matplotlib.pyplot.subplots_adjust(函數(shù)名)
matplotlib.pyplot.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
(前四個含義——單獨子圖的參數(shù)調(diào)整:左、下、右、上預留距離,默認為無。)
(后兩個含義——子圖之間的參數(shù)調(diào)整:橫向間隔距離、縱向間隔距離)
Adjust the subplot layoutparameters.(用途:子圖布局參數(shù)調(diào)整)
Unset parameters are left unmodified; initial values are given by rcParams[“figure.subplot.[name]”].
(未設置的參數(shù)保持不變;初始值由 給出 rcParams[“figure.subplot.[name]”]。)
這里涉及到 rcParams的設置,我也不太懂,可以設置字體語言和樣式這些,比如:
plt.rcParams[‘font.sans-serif'] =[‘Microsoft YaHei'] plt.rcParams[‘a(chǎn)xes.unicode_minus'] = False)
參數(shù)的官網(wǎng)解釋
1.Parameters leftfloat, optional The position of the left edge of the subplots, as a fraction of the figure width.
左:浮點數(shù),可選子圖左邊緣的位置,作為圖形寬度的一部分。
2. rightfloat, optional The position of the right edge of the subplots, as a fraction of the figure width.
右:浮點數(shù),可選子圖右邊緣的位置,作為圖形寬度的一部分。
3. bottomfloat, optional The position of the bottom edge of the subplots, as a fraction of the figure height.
底部:浮點數(shù),可選子圖底部邊緣的位置,作為圖形高度的一部分。
4. topfloat, optional The position of the top edge of the subplots, as a fraction of the figure height.
頂部:浮點數(shù),可選子圖上邊緣的位置,作為圖形高度的一部分。
5.wspacefloat, optional The width of the padding between subplots, as a fraction of the average Axes width.
wspace:浮點數(shù),可選子圖之間的填充寬度,作為平均軸寬度的一部分。
6.hspacefloat, optional The height of the padding between subplots, as a fraction of the average Axes height.
hspace:浮點數(shù),可選子圖之間的填充高度,作為平均軸高度的一部分。
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Python實現(xiàn)的根據(jù)IP地址計算子網(wǎng)掩碼位數(shù)功能示例
這篇文章主要介紹了Python實現(xiàn)的根據(jù)IP地址計算子網(wǎng)掩碼位數(shù)功能,涉及Python數(shù)值運算相關操作技巧,需要的朋友可以參考下2018-05-05centos+nginx+uwsgi部署django項目上線
本文主要介紹了centos+nginx+uwsgi部署django項目上線,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-07-07