简体   繁体   中英

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

I have just started learning Python , I am analyzing a data from .csv file and I want to separate figures, but I am getting all the plots in one graph and I am not able to separate the graphs. Please help!

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

This is the image i got ,but I want separate graphs:

在此处输入图片说明

You could always take a look at using subplot() , which would work as follows:

import matplotlib.pyplot as plt

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

plt.show()

This would display the following in a single figure:

十个子图

Just use a new 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

Each figure uses a lot of memory. So use it sparingly. Learn about clf() and cla() and savefig() if you have too many figures ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM