工作曲线绘制
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 21:55:19 2019
@author: dell
"""
import xlrd
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
def getdata():
book = xlrd.open_workbook("1.xlsx")
table = book.sheet_by_index(3)
nrows = table.nrows
data=[]
[data.append(table.row_values(i)[3:5]) for i in range(2,nrows)]
return([np.array(data)[:,0],np.array(data)[:,1]])
def smo(a,b,c,d,e):
c1 = (-3*a+12*b+17*c+12*d-3*e)/35
return(c1)
x = getdata()[0]
y = getdata()[1]
for j in range(50):
for i in range(2,229):
y[i] = smo(y[i-2],y[i-1],y[i],y[i+1],y[i+2])
plt.title('双室微生物燃料电池工作电压-时间图线')
plt.ylabel('电压/V')
plt.xlabel('时间/min')
#plt.legend(loc='lower right')
plt.plot(x,y)
plt.show()
CV图线
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 13:58:57 2019
@author: dell
"""
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
ax = plt.gca()
ax.invert_xaxis()
def dataget(name):
with open("%s.txt"%(name),'r') as file_object:
gottxt=[]
for line in file_object:
str0 = line.rstrip('\n')
lines = str0.split(',',1)
gottxt.append(lines)
gottxt = gottxt[34:]
return(gottxt)
def sl2fl(sl):
label=[float(value[0]) for value in sl]
yval=[float(value[1]) for value in sl]
return([label,yval])
N2 = sl2fl(dataget('N2-0')[2400:])
x1 = N2[0]
y1 = N2[1]
O2 = sl2fl(dataget('O2-0')[:2420])
x2 = O2[0]
y2 = O2[1]
plt.plot(x1,y1,label='N$_{2}$')
plt.plot(x2,y2,label='O$_{2}$')
plt.annotate('氧化还原电流峰\n(0.0232426,7.7995*10$^{-5}$)', xy=(0.0232426,7.7995e-5), xytext=(-0.2, 0.000125),\
arrowprops=dict(facecolor='black', shrink=0.05),\
)
plt.title('N$_{2}$与O$_{2}$环境下的CV图线')
plt.xlabel('电压/V')
plt.ylabel('电流/A')
plt.legend(loc='upper left')
plt.show()
LSV图线
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 12:49:24 2019
@author: dell
"""
import matplotlib.pyplot as plt