@@ -171,15 +171,23 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
171
171
#! TODO: Not current implemented; just use subplot for now
172
172
173
173
if (Plot ):
174
+ # Create a unique label to fix bug in matplotlib<=2.1
175
+ # See https://github.com/matplotlib/matplotlib/issues/9024
176
+ import random
177
+ figlabel = str (random .randint (1 , 1e6 ))
178
+
174
179
# Magnitude plot
175
- ax_mag = plt .subplot (211 );
180
+ ax_mag = plt .subplot (211 , label = figlabel );
181
+
176
182
if dB :
177
- pltline = ax_mag .semilogx (omega_plot , 20 * np .log10 (mag ), * args , ** kwargs )
183
+ pltline = ax_mag .semilogx (omega_plot , 20 * np .log10 (mag ),
184
+ * args , ** kwargs )
178
185
else :
179
186
pltline = ax_mag .loglog (omega_plot , mag , * args , ** kwargs )
180
187
181
188
if nyquistfrq_plot :
182
- ax_mag .axvline (nyquistfrq_plot , color = pltline [0 ].get_color ())
189
+ ax_mag .axvline (nyquistfrq_plot ,
190
+ color = pltline [0 ].get_color ())
183
191
184
192
# Add a grid to the plot + labeling
185
193
ax_mag .grid (True , which = 'both' )
@@ -354,27 +362,32 @@ def gangof4_plot(P, C, omega=None):
354
362
S = feedback (1 , L );
355
363
T = L * S ;
356
364
357
- # Plot the four sensitivity functions
365
+ # Create a unique label to fix bug in matplotlib<=2.1
366
+ # See https://github.com/matplotlib/matplotlib/issues/9024
367
+ import random
368
+ figlabel = str (random .randint (1 , 1e6 ))
369
+
370
+ # Plot the four sensitivity functions
358
371
#! TODO: Need to add in the mag = 1 lines
359
372
mag_tmp , phase_tmp , omega = T .freqresp (omega );
360
373
mag = np .squeeze (mag_tmp )
361
374
phase = np .squeeze (phase_tmp )
362
- plt .subplot (221 ); plt .loglog (omega , mag );
375
+ plt .subplot (221 , label = figlabel ); plt .loglog (omega , mag );
363
376
364
377
mag_tmp , phase_tmp , omega = (P * S ).freqresp (omega );
365
378
mag = np .squeeze (mag_tmp )
366
379
phase = np .squeeze (phase_tmp )
367
- plt .subplot (222 ); plt .loglog (omega , mag );
380
+ plt .subplot (222 , label = figlabel ); plt .loglog (omega , mag );
368
381
369
382
mag_tmp , phase_tmp , omega = (C * S ).freqresp (omega );
370
383
mag = np .squeeze (mag_tmp )
371
384
phase = np .squeeze (phase_tmp )
372
- plt .subplot (223 ); plt .loglog (omega , mag );
385
+ plt .subplot (223 , label = figlabel ); plt .loglog (omega , mag );
373
386
374
387
mag_tmp , phase_tmp , omega = S .freqresp (omega );
375
388
mag = np .squeeze (mag_tmp )
376
389
phase = np .squeeze (phase_tmp )
377
- plt .subplot (224 ); plt .loglog (omega , mag );
390
+ plt .subplot (224 , label = figlabel ); plt .loglog (omega , mag );
378
391
379
392
#
380
393
# Utility functions
0 commit comments