motplotlib画出txt文件里的数据

txt文件里有多组数据,如何能全部读取并用motplotlib分幅画出来,例如:
0 1.1 0 6.1
1 4.2 1 8.2
2 6.6 2 5.5
3 5.2 3 9.2
4 6.3 4 8.3

读取用readline就可以每次读取一行,再以空格作为分隔符取数据,这样一行的数据就获取到了。基本思路就这样,代码自己写吧

import numpy as np
import matplotlib.pyplot as plt
filename = 'C:\\Users\\dell\\Desktop\\program\\data.txt'

data = np.loadtxt(filename)                                                              
x1,y1,x2,y2 = [],[],[],[]
for i in range(len(data)):
    x1.append(data[i][0])
    y1.append(data[i][1])  
    x2.append(data[i][2])  
    y2.append(data[i][3])                                       
#创建两个figure
fig1,fig2 = plt.figure(1),plt.figure(2)

ax1,ax2 = fig1.add_subplot(111),fig2.add_subplot(111)
#-------第一个图
ax1.plot(x1,y1)
#-------第二个图
ax2.plot(x2,y2)
plt.show()

这里的filename 切换到你的data的路径