|
100 | 100 |
|
101 | 101 | plt.figure(6) |
102 | 102 | plt.clf() |
103 | | -plt.subplot(221) |
104 | 103 | bode(L, logspace(-4, 3)) |
105 | 104 |
|
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-') |
109 | 110 |
|
110 | 111 | # Re-plot phase starting at -90 degrees |
111 | 112 | mag, phase, w = freqresp(L, logspace(-4, 3)) |
112 | 113 | phase = phase - 360 |
113 | 114 |
|
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]) |
118 | 121 | plt.xlabel('Frequency [deg]') |
119 | 122 | plt.ylabel('Phase [deg]') |
120 | 123 | # plt.set(gca, 'YTick', [-360, -270, -180, -90, 0]) |
|
0 commit comments