Matplotlib无法正确显示数据,Y轴超出比例

时间:2019-06-06 15:39:44

标签: python python-3.x matplotlib graph

我目前正在我的第一个python项目中工作,我正在尝试制作一个实时图表,其中包含一些用逗号分隔的数据,这些数据已保存在文本文件中。数据看起来像是在图表上并且可以正确读取,但是以一种非常怪异的方式显示,似乎完全超出范围并且是错误的。这是我写的:

    def refresh_graph_data(i):
    print("refreshing data")
    graphdata = open('SubData.txt','r').read()
    lines=graphdata.split("\n")
    tval=[]
    subval=[]
    for line in lines:
        if len(line)>0:
            t,sub=line.split(",")
            tval.append(t)
            subval.append(sub)
    ax.clear()
    ax.plot(tval, subval)
ani=animation.FuncAnimation(fig, refresh_graph_data, interval=5000)
plt.show()



picture of graph

数据文件:
161028,202278
161229,202290
163429,202278
164229,202250
164423,202278
164451,202278
164535,202280
164610,202290

0 个答案:

没有答案