-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgen_accuracy_figs.py
94 lines (72 loc) · 2.89 KB
/
gen_accuracy_figs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import matplotlib as mpl
# mpl.rcParams['text.usetex'] = True
# Change these values to get the plots that you need.
prefix = 'slide_example'
ekf_data = np.load('ekf_'+prefix+'_res.npz')
fg_data = np.load('fg_'+prefix+'_res.npz')
truth = ekf_data['truth']
ekf_res = ekf_data['ekf_ref'] # ref is a typo. should be res=results
fg_res = fg_data['fg_res']
####### Figure 1
plt.figure()
plt.plot(ekf_res[:,0],ekf_res[:,1],c='b', label='estimate')
plt.plot(truth[:,0],truth[:,1],'r--',label='truth')
plt.legend(loc='center left', bbox_to_anchor=(0.5,0.5))
plt.grid(which='major',linestyle='-.', color = '#CCCCCC')
ax=plt.gca()
ax.set_aspect('equal')
ax.spines['left'].set_position('zero')
ax.spines['bottom'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
# Add a box around the plot
x_min, x_max = ax.get_xlim()
y_min, y_max = ax.get_ylim()
ax.axhline(y_min, color='gray', linewidth=1.5)
ax.axhline(y_max, color='gray', linewidth=1)
ax.axvline(x_min, color='gray', linewidth=1)
ax.axvline(x_max, color='gray', linewidth=1.5)
formatter=FuncFormatter(lambda x, pos: f"{x/1E6:.0f}")
ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
# Set axis labels outside the figure with the spine location in inches
ax.set_xlabel(r'x (m$\times 10^6$)', labelpad=65) # Adjust labelpad as needed
ax.set_ylabel(r'y (m$\times 10^6$)', labelpad=85) # Adjust labelpad as needed
yticks = plt.yticks()
print(type(yticks[0]),type(yticks[1]))
print(yticks[0])
yticks[1][1].set_visible(False)
print((yticks[1]))
plt.savefig('ekf_'+prefix+'.pdf',bbox_inches='tight')
######### Figure 2
plt.figure()
plt.plot(fg_res[:,0],fg_res[:,1],c='b', label='estimate')
plt.plot(truth[:,0],truth[:,1],'r--',label='truth')
plt.grid(which='major',linestyle='-.', color='#CCCCCC')
plt.legend(loc='center left', bbox_to_anchor=(0.5,0.5))
ax=plt.gca()
ax.set_aspect('equal')
ax.spines['left'].set_position('zero')
ax.spines['bottom'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
# Add a box around the plot
x_min, x_max = ax.get_xlim()
y_min, y_max = ax.get_ylim()
ax.axhline(y_min, color='gray', linewidth=1.5)
ax.axhline(y_max, color='gray', linewidth=1)
ax.axvline(x_min, color='gray', linewidth=1)
ax.axvline(x_max, color='gray', linewidth=1.5)
formatter=FuncFormatter(lambda x, pos: f"{x/1E6:.0f}")
ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
# Set axis labels outside the figure with the spine location in inches
ax.set_xlabel(r'x (m$\times 10^6$)', labelpad=65) # Adjust labelpad as needed
ax.set_ylabel(r'y (m$\times 10^6$)', labelpad=85) # Adjust labelpad as needed
# ax.set_xlabel('x (m x 1E6)', labelpad=45)
# ax.set_ylabel('y (m x 1E6)', position=(0,1))
plt.savefig('fg_'+prefix+'.pdf',bbox_inches='tight')
plt.show()