代码拉取完成,页面将自动刷新
import numpy as np
import matplotlib.pyplot as plt
import pylab
def display_val_time(val,ti,sttime):
'''
x/y:time/value ,sttime means the date to do the measurement
'''
x = [] ; y = []
for i in range(0,len(val)):
x.append(i)
y.append(val[i])
fig,ax = plt.subplots()
xticks = range(0,len(val),1)
xticks.append(len(val)-0.5)
rminy = min(y) ; rmaxy = max(y)
if rminy >= 0.5:rminy = int(rminy - 0.5)
if int(rmaxy) < 14:rmaxy = int (rmaxy) + 1
yticks = []
for i in range(rminy,rmaxy):
yticks.append(i)
yticks.append(i+0.5)
yticks.append(rmaxy)
#yticks = range(rminy,rmaxy+1,1)
ax.plot(x,y)
#set the time string
ax.set_xticks(xticks)
ax.set_xticklabels(ti,rotation=15)
ax.set_yticks(yticks)
#other setting
plt.subplots_adjust(left=0.1, right=0.93, wspace=0.25, hspace=0.45,top=0.94,bottom=0.15)
plt.xlabel('time')
plt.ylabel('pH')
plt.grid(True)
plt.title('pH measurment '+sttime)
plt.show()
if __name__ == '__main__': #test
import time
import random
va = [];ti = [];st = time.strftime("%Y/%m/%d",time.localtime())
for i in range(0,10):
va.append(random.uniform(1.0,11.0))
#time.sleep(1)
ti.append(time.strftime('%H:%M:%S',time.localtime(i)))
display_val_time(va,ti,st)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。