Skip to content

Commit c93d913

Browse files
authored
Fix issue #309: examples/pvtol-nested-ss.py plotting (#361)
1 parent ec8cbf0 commit c93d913

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

control/freqplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def bode_plot(syslist, omega=None,
101101
If True, plot phase in degrees (else radians). Default value (True)
102102
config.defaults['bode.deg']
103103
Plot : bool
104-
If True, plot magnitude and phase
104+
If True (default), plot magnitude and phase
105105
omega_limits: tuple, list, ... of two values
106106
Limits of the to generate frequency vector.
107107
If Hz=True the limits are in Hz otherwise in rad/s.

examples/pvtol-nested-ss.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,24 @@
100100

101101
plt.figure(6)
102102
plt.clf()
103-
plt.subplot(221)
104103
bode(L, logspace(-4, 3))
105104

106-
# Add crossover line
107-
plt.subplot(211)
108-
plt.loglog([1e-4, 1e3], [1, 1], 'k-')
105+
# Add crossover line to magnitude plot
106+
for ax in plt.gcf().axes:
107+
if ax.get_label() == 'control-bode-magnitude':
108+
break
109+
ax.semilogx([1e-4, 1e3], 20*np.log10([1, 1]), 'k-')
109110

110111
# Re-plot phase starting at -90 degrees
111112
mag, phase, w = freqresp(L, logspace(-4, 3))
112113
phase = phase - 360
113114

114-
plt.subplot(212)
115-
plt.semilogx([1e-4, 1e3], [-180, -180], 'k-')
116-
plt.semilogx(w, np.squeeze(phase), 'b-')
117-
plt.axis([1e-4, 1e3, -360, 0])
115+
for ax in plt.gcf().axes:
116+
if ax.get_label() == 'control-bode-phase':
117+
break
118+
ax.semilogx([1e-4, 1e3], [-180, -180], 'k-')
119+
ax.semilogx(w, np.squeeze(phase), 'b-')
120+
ax.axis([1e-4, 1e3, -360, 0])
118121
plt.xlabel('Frequency [deg]')
119122
plt.ylabel('Phase [deg]')
120123
# plt.set(gca, 'YTick', [-360, -270, -180, -90, 0])

0 commit comments

Comments
 (0)