@@ -32,19 +32,21 @@ def damposc_update(t, x, u, params):
3232fig .set_tight_layout (True )
3333plt .suptitle ("FBS Figure 5.3: damped oscillator" )
3434
35- ct .phase_plane_plot (damposc , [- 1 , 1 , - 1 , 1 ], 8 , ax = ax1 )
35+ ct .phase_plane_plot (damposc , [- 1 , 1 , - 1 , 1 ], 8 , ax = ax1 , plot_streamlines = True )
3636ax1 .set_title ("boxgrid [-1, 1, -1, 1], 8" )
3737
38- ct .phase_plane_plot (damposc , [- 1 , 1 , - 1 , 1 ], ax = ax2 , gridtype = 'meshgrid' )
38+ ct .phase_plane_plot (damposc , [- 1 , 1 , - 1 , 1 ], ax = ax2 , plot_streamlines = True ,
39+ gridtype = 'meshgrid' )
3940ax2 .set_title ("meshgrid [-1, 1, -1, 1]" )
4041
4142ct .phase_plane_plot (
42- damposc , [- 1 , 1 , - 1 , 1 ], 4 , ax = ax3 , gridtype = 'circlegrid' , dir = 'both' )
43+ damposc , [- 1 , 1 , - 1 , 1 ], 4 , ax = ax3 , plot_streamlines = True ,
44+ gridtype = 'circlegrid' , dir = 'both' )
4345ax3 .set_title ("circlegrid [0, 0, 1], 4, both" )
4446
4547ct .phase_plane_plot (
4648 damposc , [- 1 , 1 , - 1 , 1 ], ax = ax4 , gridtype = 'circlegrid' ,
47- dir = 'reverse' , gridspec = [0.1 , 12 ], timedata = 5 )
49+ plot_streamlines = True , dir = 'reverse' , gridspec = [0.1 , 12 ], timedata = 5 )
4850ax4 .set_title ("circlegrid [0, 0, 0.1], reverse" )
4951
5052#
@@ -63,21 +65,23 @@ def invpend_update(t, x, u, params):
6365plt .suptitle ("FBS Figure 5.4: inverted pendulum" )
6466
6567ct .phase_plane_plot (
66- invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], 5 , ax = ax1 )
68+ invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], 5 , ax = ax1 , plot_streamlines = True )
6769ax1 .set_title ("default, 5" )
6870
6971ct .phase_plane_plot (
70- invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], gridtype = 'meshgrid' , ax = ax2 )
72+ invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], gridtype = 'meshgrid' , ax = ax2 ,
73+ plot_streamlines = True )
7174ax2 .set_title ("meshgrid" )
7275
7376ct .phase_plane_plot (
7477 invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], 1 , gridtype = 'meshgrid' ,
75- gridspec = [12 , 9 ], ax = ax3 , arrows = 1 )
78+ gridspec = [12 , 9 ], ax = ax3 , arrows = 1 , plot_streamlines = True )
7679ax3 .set_title ("denser grid" )
7780
7881ct .phase_plane_plot (
7982 invpend , [- 2 * pi , 2 * pi , - 2 , 2 ], 4 , gridspec = [6 , 6 ],
80- plot_separatrices = {'timedata' : 20 , 'arrows' : 4 }, ax = ax4 )
83+ plot_separatrices = {'timedata' : 20 , 'arrows' : 4 }, ax = ax4 ,
84+ plot_streamlines = True )
8185ax4 .set_title ("custom" )
8286
8387#
@@ -95,28 +99,30 @@ def oscillator_update(t, x, u, params):
9599fig .set_tight_layout (True )
96100plt .suptitle ("FBS Figure 5.5: Nonlinear oscillator" )
97101
98- ct .phase_plane_plot (oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], 3 , ax = ax1 )
102+ ct .phase_plane_plot (oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], 3 , ax = ax1 ,
103+ plot_streamlines = True )
99104ax1 .set_title ("default, 3" )
100105ax1 .set_aspect ('equal' )
101106
102107try :
103108 ct .phase_plane_plot (
104109 oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], 1 , gridtype = 'meshgrid' ,
105- dir = 'forward' , ax = ax2 )
110+ dir = 'forward' , ax = ax2 , plot_streamlines = True )
106111except RuntimeError as inst :
107- axs [ 0 , 1 ] .text (0 , 0 , "Runtime Error" )
112+ ax2 .text (0 , 0 , "Runtime Error" )
108113 warnings .warn (inst .__str__ ())
109114ax2 .set_title ("meshgrid, forward, 0.5" )
110115ax2 .set_aspect ('equal' )
111116
112- ct .phase_plane_plot (oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], ax = ax3 )
117+ ct .phase_plane_plot (oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], ax = ax3 ,
118+ plot_streamlines = True )
113119pp .streamlines (
114120 oscillator , [- 0.5 , 0.5 , - 0.5 , 0.5 ], dir = 'both' , ax = ax3 )
115121ax3 .set_title ("outer + inner" )
116122ax3 .set_aspect ('equal' )
117123
118124ct .phase_plane_plot (
119- oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], 0.9 , ax = ax4 )
125+ oscillator , [- 1.5 , 1.5 , - 1.5 , 1.5 ], 0.9 , ax = ax4 , plot_streamlines = True )
120126pp .streamlines (
121127 oscillator , np .array ([[0 , 0 ]]), 1.5 ,
122128 gridtype = 'circlegrid' , gridspec = [0.5 , 6 ], dir = 'both' , ax = ax4 )
@@ -137,11 +143,11 @@ def saddle_update(t, x, u, params):
137143fig .set_tight_layout (True )
138144plt .suptitle ("FBS Figure 5.9: Saddle" )
139145
140- ct .phase_plane_plot (saddle , [- 1 , 1 , - 1 , 1 ], ax = ax1 )
146+ ct .phase_plane_plot (saddle , [- 1 , 1 , - 1 , 1 ], ax = ax1 , plot_streamlines = True )
141147ax1 .set_title ("default" )
142148
143149ct .phase_plane_plot (
144- saddle , [- 1 , 1 , - 1 , 1 ], 0.5 , gridtype = 'meshgrid' , ax = ax2 )
150+ saddle , [- 1 , 1 , - 1 , 1 ], 0.5 , gridtype = 'meshgrid' , ax = ax2 , plot_streamlines = True )
145151ax2 .set_title ("meshgrid" )
146152
147153ct .phase_plane_plot (
@@ -150,7 +156,7 @@ def saddle_update(t, x, u, params):
150156ax3 .set_title ("vectorfield" )
151157
152158ct .phase_plane_plot (
153- saddle , [- 1 , 1 , - 1 , 1 ], 0.3 ,
159+ saddle , [- 1 , 1 , - 1 , 1 ], 0.3 , plot_streamlines = True ,
154160 gridtype = 'meshgrid' , gridspec = [5 , 7 ], ax = ax4 )
155161ax3 .set_title ("custom" )
156162
@@ -182,15 +188,15 @@ def _congctrl_update(t, x, u, params):
182188
183189try :
184190 ct .phase_plane_plot (
185- congctrl , [0 , 10 , 100 , 500 ], 120 , ax = ax1 )
191+ congctrl , [0 , 10 , 100 , 500 ], 120 , ax = ax1 , plot_streamlines = True )
186192except RuntimeError as inst :
187193 ax1 .text (5 , 250 , "Runtime Error" )
188194 warnings .warn (inst .__str__ ())
189195ax1 .set_title ("default, T=120" )
190196
191197try :
192198 ct .phase_plane_plot (
193- congctrl , [0 , 10 , 100 , 500 ], 120 ,
199+ congctrl , [0 , 10 , 100 , 500 ], 120 , plot_streamlines = True ,
194200 params = {'rho' : 4e-4 , 'c' : 20 }, ax = ax2 )
195201except RuntimeError as inst :
196202 ax2 .text (5 , 250 , "Runtime Error" )
@@ -203,7 +209,7 @@ def _congctrl_update(t, x, u, params):
203209ax3 .set_title ("vector field" )
204210
205211ct .phase_plane_plot (
206- congctrl , [2 , 6 , 200 , 300 ], 100 ,
212+ congctrl , [2 , 6 , 200 , 300 ], 100 , plot_streamlines = True ,
207213 params = {'rho' : 4e-4 , 'c' : 20 },
208214 ax = ax4 , plot_vectorfield = {'gridspec' : [12 , 9 ]})
209215ax4 .set_title ("vector field + streamlines" )
0 commit comments