plot.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # import matplotlib
  2. # matplotlib.use('Agg')
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. #######for ikfom
  6. fig, axs = plt.subplots(4,2)
  7. lab_pre = ['', 'pre-x', 'pre-y', 'pre-z']
  8. lab_out = ['', 'out-x', 'out-y', 'out-z']
  9. plot_ind = range(7,10)
  10. a_pre=np.loadtxt('mat_pre.txt')
  11. a_out=np.loadtxt('mat_out.txt')
  12. time=a_pre[:,0]
  13. axs[0,0].set_title('Attitude')
  14. axs[1,0].set_title('Translation')
  15. axs[2,0].set_title('Extrins-R')
  16. axs[3,0].set_title('Extrins-T')
  17. axs[0,1].set_title('Velocity')
  18. axs[1,1].set_title('bg')
  19. axs[2,1].set_title('ba')
  20. axs[3,1].set_title('Gravity')
  21. for i in range(1,4):
  22. for j in range(8):
  23. axs[j%4, j/4].plot(time, a_pre[:,i+j*3],'.-', label=lab_pre[i])
  24. axs[j%4, j/4].plot(time, a_out[:,i+j*3],'.-', label=lab_out[i])
  25. for j in range(8):
  26. # axs[j].set_xlim(386,389)
  27. axs[j%4, j/4].grid()
  28. axs[j%4, j/4].legend()
  29. plt.grid()
  30. #######for ikfom#######
  31. #### Draw IMU data
  32. # fig, axs = plt.subplots(2)
  33. # imu=np.loadtxt('imu.txt')
  34. # time=imu[:,0]
  35. # axs[0].set_title('Gyroscope')
  36. # axs[1].set_title('Accelerameter')
  37. # lab_1 = ['gyr-x', 'gyr-y', 'gyr-z']
  38. # lab_2 = ['acc-x', 'acc-y', 'acc-z']
  39. # for i in range(3):
  40. # # if i==1:
  41. # axs[0].plot(time, imu[:,i+1],'.-', label=lab_1[i])
  42. # axs[1].plot(time, imu[:,i+4],'.-', label=lab_2[i])
  43. # for i in range(2):
  44. # # axs[i].set_xlim(386,389)
  45. # axs[i].grid()
  46. # axs[i].legend()
  47. # plt.grid()
  48. # #### Draw time calculation
  49. # plt.figure(3)
  50. # fig = plt.figure()
  51. # font1 = {'family' : 'Times New Roman',
  52. # 'weight' : 'normal',
  53. # 'size' : 12,
  54. # }
  55. # c="red"
  56. # a_out1=np.loadtxt('Log/mat_out_time_indoor1.txt')
  57. # a_out2=np.loadtxt('Log/mat_out_time_indoor2.txt')
  58. # a_out3=np.loadtxt('Log/mat_out_time_outdoor.txt')
  59. # # n = a_out[:,1].size
  60. # # time_mean = a_out[:,1].mean()
  61. # # time_se = a_out[:,1].std() / np.sqrt(n)
  62. # # time_err = a_out[:,1] - time_mean
  63. # # feat_mean = a_out[:,2].mean()
  64. # # feat_err = a_out[:,2] - feat_mean
  65. # # feat_se = a_out[:,2].std() / np.sqrt(n)
  66. # ax1 = fig.add_subplot(111)
  67. # ax1.set_ylabel('Effective Feature Numbers',font1)
  68. # ax1.boxplot(a_out1[:,2], showfliers=False, positions=[0.9])
  69. # ax1.boxplot(a_out2[:,2], showfliers=False, positions=[1.9])
  70. # ax1.boxplot(a_out3[:,2], showfliers=False, positions=[2.9])
  71. # ax1.set_ylim([0, 3000])
  72. # ax2 = ax1.twinx()
  73. # ax2.spines['right'].set_color('red')
  74. # ax2.set_ylabel('Compute Time (ms)',font1)
  75. # ax2.yaxis.label.set_color('red')
  76. # ax2.tick_params(axis='y', colors='red')
  77. # ax2.boxplot(a_out1[:,1]*1000, showfliers=False, positions=[1.1],boxprops=dict(color=c),capprops=dict(color=c),whiskerprops=dict(color=c))
  78. # ax2.boxplot(a_out2[:,1]*1000, showfliers=False, positions=[2.1],boxprops=dict(color=c),capprops=dict(color=c),whiskerprops=dict(color=c))
  79. # ax2.boxplot(a_out3[:,1]*1000, showfliers=False, positions=[3.1],boxprops=dict(color=c),capprops=dict(color=c),whiskerprops=dict(color=c))
  80. # ax2.set_xlim([0.5, 3.5])
  81. # ax2.set_ylim([0, 100])
  82. # plt.xticks([1,2,3], ('Outdoor Scene', 'Indoor Scene 1', 'Indoor Scene 2'))
  83. # # # print(time_se)
  84. # # # print(a_out3[:,2])
  85. # plt.grid()
  86. # plt.savefig("time.pdf", dpi=1200)
  87. plt.show()