#####python3 读取txt数据
file_path_gins=“/data/gins.txt”
time=[]
gnss_pos_x=[]
gnss_pos_y = []
gnss_pos_z = []
gins_pos_x = []
gins_pos_y = []
gins_pos_z = []
gins_data=[]
with open(file_path_gins,“rb”) as file:
lines=file.readlines()
for line in lines:
linedata=line.strip().split()
gins_data.append(linedata)
for i in range(0,len(gins_data)):
time.append(float(gins_data[i][0]))
gnss_pos_x(float(gins_data[i][1]))
gnss_pos_y(float(gins_data[i][2]))
gnss_pos_z(float(gins_data[i][3]))
gins_pos_x(float(gins_data[i][4]))
gins_pos_y(float(gins_data[i][5]))
gins_pos_z(float(gins_data[i][6]))
python3绘图
###散点图
figure1=plt.figure()
plt.subplot(2,2,1)
p1=plt.scatter(x=gnss_pos_x,y=gnss_pos_y,s=2.5,colcor=“r”,marker=‘.’)
p2 = plt.scatter(x = gins_pos_x, y = gins_pos_y, s = 2.5, colcor = “g”, marker = ‘.’)
plt.legend([p1,p2],[‘gnss_pox’,‘gins_pox’])
plt.title(‘gnss_pos vs gins_pos’)
plt.xlabel(‘x-axis’)
plt.ylabel(‘y-axis’)
##折线图
plt.subplot(2, 2, 2)
p1 = plt.plot(time,gnss_pos_x, linewith=0.5,marker = ‘.’,colcor = “r”,label=“gnss_pos_x”)
plt.legend()
p1 = plt.plot(time, gins_pos_x, linewith = 0.5, marker = ‘.’, colcor = “g”, label = “gins_pos_x”)
plt.legend()
plt.title(‘gnss_pos _x vs gins_pos_x’)
plt.xlabel(‘x-axis’)
plt.ylabel(‘y-axis’)
plt.show()