簡體   English   中英

Matplotlib:從函數返回的AXes插入到新的子圖中

[英]Matplotlib: returned AXes from functions to be inserted into new subplots

因此,我具有這兩個函數來繪制timeSeries和直方圖。

ax1 = plotTimeSeries(df=dfDelay_Vector)
ax2 = plotHistogram( df=dfDelay_Hist)

每個人都返回一個ax對象,他們都產生一個情節。 到現在為止還挺好。

現在,我有了一個新功能,該功能試圖將這些圖引入子圖。 axes是一個列表,例如axes = [ax1,ax2]

def drawSubPlots(rows, cols, axes):
    fig, ax = plt.subplots(rows, cols)
    for i in range(len(axes)):
        ax[i] = axes[i]

...但是我得到的只是一個空洞的數字。

在此處輸入圖片說明

如何將返回的軸插入新的子圖中?

謝謝!

因此,在聽取了上述人士的建議后,我得出以下結論:

fig, ax = drawSubPlots(2,1)
ax1     = plotTimeSeries(df=dfDelay_Vector, ax=ax[0] )
ax2     = plotHistogram( df=dfDelay_Hist,   ax=ax[1] ) 

這樣做,生成下一個子圖:

在此處輸入圖片說明

仍然需要自己調整圖(xtickslabels的方向,字體大小,在子圖中保持系列的顏色,直方圖中條形的大小),但主要內容已涵蓋!

謝謝!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM