import matplotlib.pyplot as plt
import pygal
import re
#读取文件
fp = open(r'C:\Users\yangwenbin\Desktop\output.txt', 'r')
arr=[]
i=0
new_numbers = []
for ln in fp: #按行读取
res = re.findall(r"\d+\.?\d*",ln) #读取每行的数字
for n in res: #将每行的字符数字转成float型
new_numbers.append(float(n))
i=i+1
hist=pygal.Bar()
hist.title="zhifangtu"
hist.x_labels=['1','2','3','4','5','6','7','8']
hist.y_title="abc"
#print(new_numbers)
hist.add('d6',new_numbers)
hist.render_to_file(str(i)+'.svg') #存储svg格式
del new_numbers[:] #删除上一次存在列表new_numbers的数
import matplotlib.pyplot as plt
import numpy as np
import re
#读取文件
fp = open(r'C:\Users\yangwenbin\Desktop\output.txt', 'r')
arr=[]
i=0
new_numbers = []
for ln in fp: #按行读取
#print(ln)
res = re.findall(r"\d+\.?\d*",ln)
#print(res)
#arr1=''.join(res)
for n in res:
new_numbers.append(float(n))
index=np.arange(3)
plt.bar(left=index,height=new_numbers,color='green',width=0.5)
#plt.show()
plt.savefig(str(i)+'.png',bbox_inches='tight')#存为png格式
i=i+1
del new_numbers[:]
0.0878661 0.0251046 0.351464 0.0449791 0.0690377 0 0.420502 0.00104603
0.043088 0.0394973 0.375224 0.0502693 0.02693 0.070018 0.330341 0.064632
0.064 0.046 0.336 0.066 0.04 0.052 0.348 0.048
0.0315789 0.0894737 0.289474 0.1 0.0105263 0.131579 0.226316 0.121053
0.0770609 0.108423 0.206989 0.108423 0.0752688 0.0761649 0.273297 0.0743728
0.132003 0.128166 0.130468 0.0890253 0.172678 0.10284 0.140445 0.104375
0.0961538 0.105769 0.163462 0.115385 0.134615 0.0769231 0.182692 0.125
0.186813 0.0934066 0.137363 0.0604396 0.230769 0.0769231 0.126374 0.0879121
0.301653 0.0619835 0.0640496 0.109504 0.227273 0.0867769 0.088843 0.0599174
0.174312 0.0917431 0.155963 0.119266 0.0917431 0.155963 0.110092 0.100917
0.138889 0.166667 0.0277778 0.166667 0.138889 0.138889 0.0833333 0.138889
0.212644 0.0881226 0.0996169 0.103448 0.204981 0.0862069 0.111111 0.0938697
0.0935252 0.115108 0.179856 0.122302 0.0719424 0.115108 0.201439 0.100719
0.244624 0.115591 0.0645161 0.0564516 0.282258 0.0967742 0.0645161 0.0752688
0.294872 0.0854701 0.0512821 0.0811966 0.269231 0.0982906 0.0512821 0.0683761
0.284264 0.0812183 0.101523 0.0101523 0.329949 0.0913706 0.035533 0.0659898
0.235521 0.104247 0.0926641 0.0656371 0.239382 0.108108 0.0810811 0.0733591