Skip to content

Commit cf8303b

Browse files
committed
added explicit plot_streamlines=True in examples
1 parent 1f702f6 commit cf8303b

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

examples/phase_plane_plots.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ def damposc_update(t, x, u, params):
3232
fig.set_tight_layout(True)
3333
plt.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)
3636
ax1.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')
3940
ax2.set_title("meshgrid [-1, 1, -1, 1]")
4041

4142
ct.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')
4345
ax3.set_title("circlegrid [0, 0, 1], 4, both")
4446

4547
ct.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)
4850
ax4.set_title("circlegrid [0, 0, 0.1], reverse")
4951

5052
#
@@ -63,21 +65,23 @@ def invpend_update(t, x, u, params):
6365
plt.suptitle("FBS Figure 5.4: inverted pendulum")
6466

6567
ct.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)
6769
ax1.set_title("default, 5")
6870

6971
ct.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)
7174
ax2.set_title("meshgrid")
7275

7376
ct.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)
7679
ax3.set_title("denser grid")
7780

7881
ct.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)
8185
ax4.set_title("custom")
8286

8387
#
@@ -95,28 +99,30 @@ def oscillator_update(t, x, u, params):
9599
fig.set_tight_layout(True)
96100
plt.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)
99104
ax1.set_title("default, 3")
100105
ax1.set_aspect('equal')
101106

102107
try:
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)
106111
except RuntimeError as inst:
107-
axs[0,1].text(0, 0, "Runtime Error")
112+
ax2.text(0, 0, "Runtime Error")
108113
warnings.warn(inst.__str__())
109114
ax2.set_title("meshgrid, forward, 0.5")
110115
ax2.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)
113119
pp.streamlines(
114120
oscillator, [-0.5, 0.5, -0.5, 0.5], dir='both', ax=ax3)
115121
ax3.set_title("outer + inner")
116122
ax3.set_aspect('equal')
117123

118124
ct.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)
120126
pp.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):
137143
fig.set_tight_layout(True)
138144
plt.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)
141147
ax1.set_title("default")
142148

143149
ct.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)
145151
ax2.set_title("meshgrid")
146152

147153
ct.phase_plane_plot(
@@ -150,7 +156,7 @@ def saddle_update(t, x, u, params):
150156
ax3.set_title("vectorfield")
151157

152158
ct.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)
155161
ax3.set_title("custom")
156162

@@ -182,15 +188,15 @@ def _congctrl_update(t, x, u, params):
182188

183189
try:
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)
186192
except RuntimeError as inst:
187193
ax1.text(5, 250, "Runtime Error")
188194
warnings.warn(inst.__str__())
189195
ax1.set_title("default, T=120")
190196

191197
try:
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)
195201
except RuntimeError as inst:
196202
ax2.text(5, 250, "Runtime Error")
@@ -203,7 +209,7 @@ def _congctrl_update(t, x, u, params):
203209
ax3.set_title("vector field")
204210

205211
ct.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]})
209215
ax4.set_title("vector field + streamlines")

0 commit comments

Comments
 (0)