6
6
from matplotlib .offsetbox import TextArea , DrawingArea , OffsetImage , AnnotationBbox
7
7
8
8
9
-
10
9
class BayesFilterBoat (object ):
11
10
12
11
def __init__ (self ):
@@ -18,22 +17,37 @@ def main(self):
18
17
self ._draw_main_window ()
19
18
20
19
def _draw_main_window (self ):
21
- # self.fig, self.axs = plt.subplots(1, 3, figsize=(12, 4))
22
-
23
- self .fig = plt .figure (figsize = (10 , 8 ))
20
+ self .fig = plt .figure (figsize = (10 , 8 ), constrained_layout = False )
24
21
gs = self .fig .add_gridspec (2 , 2 )
25
22
26
23
# sim axis
27
24
self .ax_sim = self .fig .add_subplot (gs [0 , :])
28
25
self .ax_sim .set_title ('Simulation' )
26
+ self .set_ylim (self .ax_sim )
27
+ self .ax_sim .set_xlim (- 1 , 11 )
29
28
30
29
# Mesurement model
31
30
self .ax_me = self .fig .add_subplot (gs [1 , 0 ])
32
- self .ax_me .set_title ('Mesurement Model' )
31
+
32
+ self .me_y = np .ones (shape = (3 ,))/ 3
33
+ self .me_x = np .arange (len (self .me_y )) - 1
34
+
35
+ self .ax_me .set_title (r'Mesurement model $p(Z_t|X_t)$' )
36
+ bar_plot (self .ax_me , self .me_x , self .me_y , color = 'r' )
37
+ self .set_ylim (self .ax_me )
33
38
34
39
# Motion model
35
40
self .ax_mo = self .fig .add_subplot (gs [1 , 1 ])
36
- self .ax_mo .set_title ('Motion Model' )
41
+ self .ax_mo .set_title (r'Motion model $p(X_{t+1}|X_t)$' )
42
+
43
+ self .mo_p = [0 , 0.75 , 0.25 ]
44
+ self .mo_y = np .array (self .mo_p )
45
+ self .mo_x = np .arange (len (self .mo_y ))
46
+
47
+ bar_plot (self .ax_mo , self .mo_x , self .mo_y , color = 'b' )
48
+ self .ax_mo .axvline (0.25 , c = 'k' , ls = '--' )
49
+ self .ax_mo .axvline (- 0.25 , c = 'k' , ls = '--' )
50
+ self .set_ylim (self .ax_mo )
37
51
38
52
line , = self .ax_sim .plot ([0 ], [0 ])
39
53
self .cid = line .figure .canvas .mpl_connect ('button_press_event' , self )
@@ -42,6 +56,11 @@ def _draw_main_window(self):
42
56
self .ys = list (line .get_ydata ())
43
57
plt .show ()
44
58
59
+ def set_ylim (self , ax ):
60
+ ax .set_ylim (0 , 1 )
61
+ ax .set_axisbelow (True )
62
+ ax .grid (ls = '--' )
63
+
45
64
def __call__ (self , event ):
46
65
# print('click', event)
47
66
if event .inaxes != self .line .axes :
0 commit comments