3 Star 3 Fork 0

fr000/raspberry_and_pH_sensor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
displayChart.py 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
fr000 提交于 2015-05-08 19:59 . init
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fr000/raspberry_and_pH_sensor.git
git@gitee.com:fr000/raspberry_and_pH_sensor.git
fr000
raspberry_and_pH_sensor
raspberry_and_pH_sensor
master

搜索帮助