当我试图绘制近30 to的数据时,为什么要等待(30秒或更长时间)?我的数据结构是正确的列表吗?还是我应该用哪一个?
import matplotlib.pyplot as plt
x1=[]
y1=[]
with open("C:\\Users\\Desktop\\33mb.txt","r") as f4:
for line in f4:
data=line.split(",")
if data[0] == "b'$GNGGA":
x1.append(float(data[1])) #plot_x
y1.append(float(data[1])) #plot_y
plt.plot(x1,y1) #plot_()
print("0")
print("finished")
plt.show() #plot_show()
print("........................")当删除绘图脚本时,它在不到1秒内读取33 It (打印数千个"0“输出)。
任何帮助都将不胜感激。
发布于 2019-02-06 14:30:05
import matplotlib.pyplot as plt
x1=[]
y1=[]
with open("C:\\Users\\Desktop\\33mb.txt","r") as f4:
for line in f4:
data=line.split(",")
if data[0] == "b'$GNGGA":
x1.append(float(data[1])) #plot_x
y1.append(float(data[1])) #plot_y
print("0")
print("finished")
plt.plot(x1,y1) #plot_()
plt.show() #plot_show()
print("........................")应该能按要求工作。plt.plot()能够同时绘制整个表内容。如果您在循环中这样做,在添加每个新的点之后,您将重复绘制和重绘,据我所知,这不是意图。
https://stackoverflow.com/questions/54555847
复制相似问题