|
40 | 40 | # SUCH DAMAGE. |
41 | 41 | # |
42 | 42 | # $Id$ |
43 | | - |
| 43 | +import matplotlib |
44 | 44 | import matplotlib.pyplot as plt |
45 | 45 | import scipy as sp |
46 | 46 | import numpy as np |
@@ -192,6 +192,7 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None, |
192 | 192 | fig = plt.gcf() |
193 | 193 | ax_mag = None |
194 | 194 | ax_phase = None |
| 195 | + sisotool = False |
195 | 196 |
|
196 | 197 | # Get the current axes if they already exist |
197 | 198 | for ax in fig.axes: |
@@ -242,47 +243,47 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None, |
242 | 243 | if Hz: |
243 | 244 | Wcg, Wcp = Wcg/(2*math.pi),Wcp/(2*math.pi) |
244 | 245 |
|
245 | | - ax_mag.axhline(y=0 if dB else 1, color='k', linestyle=':') |
246 | | - ax_phase.axhline(y=phase_limit if deg else math.radians(phase_limit), color='k', linestyle=':') |
| 246 | + ax_mag.axhline(y=0 if dB else 1, color='k', linestyle=':',zorder=-20) |
| 247 | + ax_phase.axhline(y=phase_limit if deg else math.radians(phase_limit), color='k', linestyle=':',zorder=-20) |
247 | 248 | mag_ylim = ax_mag.get_ylim() |
248 | 249 | phase_ylim = ax_phase.get_ylim() |
249 | 250 |
|
250 | 251 | if pm != float('inf') and Wcp != float('nan'): |
251 | 252 | if dB: |
252 | | - ax_mag.semilogx([Wcp, Wcp], [0.,-1e5],color='k', linestyle=':') |
| 253 | + ax_mag.semilogx([Wcp, Wcp], [0.,-1e5],color='k', linestyle=':',zorder=-20) |
253 | 254 | else: |
254 | | - ax_mag.loglog([Wcp,Wcp], [1.,1e-8],color='k',linestyle=':') |
| 255 | + ax_mag.loglog([Wcp,Wcp], [1.,1e-8],color='k',linestyle=':',zorder=-20) |
255 | 256 |
|
256 | 257 | if deg: |
257 | | - ax_phase.semilogx([Wcp, Wcp], [1e5, phase_limit+pm],color='k', linestyle=':') |
258 | | - ax_phase.semilogx([Wcp, Wcp], [phase_limit + pm, phase_limit],color='k') |
| 258 | + ax_phase.semilogx([Wcp, Wcp], [1e5, phase_limit+pm],color='k', linestyle=':',zorder=-20) |
| 259 | + ax_phase.semilogx([Wcp, Wcp], [phase_limit + pm, phase_limit],color='k',zorder=-20) |
259 | 260 | else: |
260 | | - ax_phase.semilogx([Wcp, Wcp], [1e5, math.radians(phase_limit)+math.radians(pm)],color='k', linestyle=':') |
261 | | - ax_phase.semilogx([Wcp, Wcp], [math.radians(phase_limit) +math.radians(pm), math.radians(phase_limit)],color='k') |
| 261 | + ax_phase.semilogx([Wcp, Wcp], [1e5, math.radians(phase_limit)+math.radians(pm)],color='k', linestyle=':',zorder=-20) |
| 262 | + ax_phase.semilogx([Wcp, Wcp], [math.radians(phase_limit) +math.radians(pm), math.radians(phase_limit)],color='k',zorder=-20) |
262 | 263 |
|
263 | 264 | if gm != float('inf') and Wcg != float('nan'): |
264 | 265 | if dB: |
265 | | - ax_mag.semilogx([Wcg, Wcg], [-20.*np.log10(gm), -1e5],color='k', linestyle=':') |
266 | | - ax_mag.semilogx([Wcg, Wcg], [0,-20*np.log10(gm)],color='k') |
| 266 | + ax_mag.semilogx([Wcg, Wcg], [-20.*np.log10(gm), -1e5],color='k', linestyle=':',zorder=-20) |
| 267 | + ax_mag.semilogx([Wcg, Wcg], [0,-20*np.log10(gm)],color='k',zorder=-20) |
267 | 268 | else: |
268 | | - ax_mag.loglog([Wcg, Wcg], [1./gm,1e-8],color='k', linestyle=':') |
269 | | - ax_mag.loglog([Wcg, Wcg], [1.,1./gm],color='k') |
| 269 | + ax_mag.loglog([Wcg, Wcg], [1./gm,1e-8],color='k', linestyle=':',zorder=-20) |
| 270 | + ax_mag.loglog([Wcg, Wcg], [1.,1./gm],color='k',zorder=-20) |
270 | 271 |
|
271 | 272 | if deg: |
272 | | - ax_phase.semilogx([Wcg, Wcg], [1e-8, phase_limit],color='k', linestyle=':') |
| 273 | + ax_phase.semilogx([Wcg, Wcg], [1e-8, phase_limit],color='k', linestyle=':',zorder=-20) |
273 | 274 | else: |
274 | | - ax_phase.semilogx([Wcg, Wcg], [1e-8, math.radians(phase_limit)],color='k', linestyle=':') |
| 275 | + ax_phase.semilogx([Wcg, Wcg], [1e-8, math.radians(phase_limit)],color='k', linestyle=':',zorder=-20) |
275 | 276 |
|
276 | 277 | ax_mag.set_ylim(mag_ylim) |
277 | 278 | ax_phase.set_ylim(phase_ylim) |
278 | 279 |
|
279 | 280 | if sisotool: |
280 | | - ax_mag.text(0.04, 0.06, 'G.M.: %.2f %s\nFreq: %.2f %s'%(20*np.log10(gm) if dB else gm,'dB ' if dB else '\b',Wcg,'Hz' if Hz else 'rad/s'), horizontalalignment='left', verticalalignment='bottom', |
281 | | - transform=ax_mag.transAxes,fontsize=10) |
| 281 | + ax_mag.text(0.04, 0.06, 'G.M.: %.2f %s\nFreq: %.2f %s'%(20*np.log10(gm) if dB else gm,'dB ' if dB else '',Wcg,'Hz' if Hz else 'rad/s'), horizontalalignment='left', verticalalignment='bottom', |
| 282 | + transform=ax_mag.transAxes,fontsize=8 if int(matplotlib.__version__[0]) == 1 else 6) |
282 | 283 | ax_phase.text(0.04, 0.06, 'P.M.: %.2f %s\nFreq: %.2f %s'%(pm if deg else math.radians(pm),'deg' if deg else 'rad',Wcp,'Hz' if Hz else 'rad/s'), horizontalalignment='left', verticalalignment='bottom', |
283 | | - transform=ax_phase.transAxes,fontsize=10) |
| 284 | + transform=ax_phase.transAxes,fontsize=8 if int(matplotlib.__version__[0]) == 1 else 6) |
284 | 285 | else: |
285 | | - plt.suptitle('Gm = %.2f %s(at %.2f %s), Pm = %.2f %s (at %.2f %s)'%(20*np.log10(gm) if dB else gm,'dB ' if dB else '\b','Hz' if Hz else 'rad/s',Wcg,pm if deg else math.radians(pm),'deg' if deg else 'rad',Wcp,'Hz' if Hz else 'rad/s')) |
| 286 | + plt.suptitle('Gm = %.2f %s(at %.2f %s), Pm = %.2f %s (at %.2f %s)'%(20*np.log10(gm) if dB else gm,'dB ' if dB else '\b',Wcg,'Hz' if Hz else 'rad/s',pm if deg else math.radians(pm),'deg' if deg else 'rad',Wcp,'Hz' if Hz else 'rad/s')) |
286 | 287 |
|
287 | 288 | if nyquistfrq_plot: |
288 | 289 | ax_phase.axvline(nyquistfrq_plot, color=pltline[0].get_color()) |
|
0 commit comments