@@ -171,15 +171,23 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
171171 #! TODO: Not current implemented; just use subplot for now
172172
173173 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+
174179 # Magnitude plot
175- ax_mag = plt .subplot (211 );
180+ ax_mag = plt .subplot (211 , label = figlabel );
181+
176182 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 )
178185 else :
179186 pltline = ax_mag .loglog (omega_plot , mag , * args , ** kwargs )
180187
181188 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 ())
183191
184192 # Add a grid to the plot + labeling
185193 ax_mag .grid (True , which = 'both' )
@@ -354,27 +362,32 @@ def gangof4_plot(P, C, omega=None):
354362 S = feedback (1 , L );
355363 T = L * S ;
356364
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
358371 #! TODO: Need to add in the mag = 1 lines
359372 mag_tmp , phase_tmp , omega = T .freqresp (omega );
360373 mag = np .squeeze (mag_tmp )
361374 phase = np .squeeze (phase_tmp )
362- plt .subplot (221 ); plt .loglog (omega , mag );
375+ plt .subplot (221 , label = figlabel ); plt .loglog (omega , mag );
363376
364377 mag_tmp , phase_tmp , omega = (P * S ).freqresp (omega );
365378 mag = np .squeeze (mag_tmp )
366379 phase = np .squeeze (phase_tmp )
367- plt .subplot (222 ); plt .loglog (omega , mag );
380+ plt .subplot (222 , label = figlabel ); plt .loglog (omega , mag );
368381
369382 mag_tmp , phase_tmp , omega = (C * S ).freqresp (omega );
370383 mag = np .squeeze (mag_tmp )
371384 phase = np .squeeze (phase_tmp )
372- plt .subplot (223 ); plt .loglog (omega , mag );
385+ plt .subplot (223 , label = figlabel ); plt .loglog (omega , mag );
373386
374387 mag_tmp , phase_tmp , omega = S .freqresp (omega );
375388 mag = np .squeeze (mag_tmp )
376389 phase = np .squeeze (phase_tmp )
377- plt .subplot (224 ); plt .loglog (omega , mag );
390+ plt .subplot (224 , label = figlabel ); plt .loglog (omega , mag );
378391
379392#
380393# Utility functions
0 commit comments