Skip to content

Commit

Permalink
Fix issue #309: examples/pvtol-nested-ss.py plotting (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
murrayrm committed Jan 4, 2020
1 parent ec8cbf0 commit c93d913
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion control/freqplot.py
Expand Up @@ -101,7 +101,7 @@ def bode_plot(syslist, omega=None,
If True, plot phase in degrees (else radians). Default value (True)
config.defaults['bode.deg']
Plot : bool
If True, plot magnitude and phase
If True (default), plot magnitude and phase
omega_limits: tuple, list, ... of two values
Limits of the to generate frequency vector.
If Hz=True the limits are in Hz otherwise in rad/s.
Expand Down
19 changes: 11 additions & 8 deletions examples/pvtol-nested-ss.py
Expand Up @@ -100,21 +100,24 @@

plt.figure(6)
plt.clf()
plt.subplot(221)
bode(L, logspace(-4, 3))

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

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

plt.subplot(212)
plt.semilogx([1e-4, 1e3], [-180, -180], 'k-')
plt.semilogx(w, np.squeeze(phase), 'b-')
plt.axis([1e-4, 1e3, -360, 0])
for ax in plt.gcf().axes:
if ax.get_label() == 'control-bode-phase':
break
ax.semilogx([1e-4, 1e3], [-180, -180], 'k-')
ax.semilogx(w, np.squeeze(phase), 'b-')
ax.axis([1e-4, 1e3, -360, 0])
plt.xlabel('Frequency [deg]')
plt.ylabel('Phase [deg]')
# plt.set(gca, 'YTick', [-360, -270, -180, -90, 0])
Expand Down

0 comments on commit c93d913

Please sign in to comment.