簡體   English   中英

如何使用matplotlib在一個大的單一圖中分別繪制圖形?

[英]How to separately plot the figures in one big single figure using matplotlib?

我剛剛開始學習Python ,我正在分析.csv文件中的數據,並且想要分離圖形,但是我將所有圖形都繪制在一個圖形中,而我無法分離圖形。 請幫忙!

n = 10
i=0
for i in range(0,n):
    inflammation = matplotlib.pyplot.plot(data[i,:40])#inflammation graph for patient 0

這是我得到的圖像,但是我想要單獨的圖形:

在此處輸入圖片說明

您可以隨時查看使用subplot() ,其工作方式如下:

import matplotlib.pyplot as plt

for n in range(1, 11):
    plt.subplot(2, 5, n)
    plt.plot(range(12))

plt.show()

這將在單個圖中顯示以下內容:

十個子圖

只需使用一個新的figure()

n = 10
i=0
for i in range(0,n):
    matplotlib.pyplot.figure()
    inflammation = matplotlib.pyplot.plot(data[i,:40]) #inflammation graph for patient 0

每個數字都占用大量內存。 因此,請謹慎使用。 如果數字太多,請了解clf()以及cla()savefig() ...

暫無
暫無

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

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