# 解析tid数据并绘制折线图
# encoding=utf-8
# 引入对应库文件
import numpy as np
import matplotlib.pyplot as plt

#读取txt文件
f = open('C:/Users/Administrator/Desktop/PythonTool/单波束数据/20180529-0605.tid','r')
list = [] #设置 y List
list1 = [] #
while True:
   line = f.readline()         #获得每一行的数据
   splitline = line.split()    #split 默认空格分隔符 
   if len(splitline)  > 2 :    #判断是否分成三份
          seaval = float(splitline[2])   #转成float
          list.append(seaval)
          list1.append(splitline[0]+' '+ splitline[1])
   if not line:
       break
       pass
x = list1  # 类似于平滑度 0表示x坐标原点的值,20表示x的最大值,100表示将值分成100份
y = list   # 条件:两个list 的length必须相同
plt.plot(x, y , 'b')  #最后一个参数表示显示折线的颜色 例如'r' = red ,'g' = green
plt.title("line")  #标题
plt.xlabel("time") #x坐标显示字符
plt.ylabel('m')    #y坐标显示字符
plt.show()

结果:

解析tid数据并绘制折线图(python)

 

相关文章:

  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2021-10-17
  • 2021-09-25
  • 2021-12-20
  • 2021-09-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案