簡體   English   中英

我有 29 個地塊,但我希望將它們排列成更少的行,我該如何在 matplotlib 上做到這一點?

[英]I have 29 plots but I want them to be ordered into less rows, how do I do that on matplotlib?

我有一個 for 循環,在其中制作了 29 個圖......

for i in range(int(len(lsds_monthly)/24)):
    plt.plot(time_months[i*24: (i+1)*24],lsds_monthly[i*24: (i+1)*24])
    plt.xticks(np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.15), rotation=35)
    plt.grid()
    plt.title('LSDS Monthly Data')
    plt.show()

現在的情節如何

您需要 plot 使用ax而不是plt

for i in range(int(len(lsds_monthly)/24)):

    # add a new subplot
    ax = plt.subplot(5, 6, i+1)

    # plot on the subplot
    ax.plot(time_months[i*24: (i+1)*24],lsds_monthly[i*24: (i+1)*24])

    # other formatting
    ax.set_xticks(np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.15), rotation=35)
    ax.grid()
    ax.title('LSDS Monthly Data')

plt.show()

暫無
暫無

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

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