@@ -174,6 +174,7 @@ def _default_gains(num, den, xlim, ylim,zoom_xlim=None,zoom_ylim=None):
174174
175175 k_break , real_break = _break_points (num , den )
176176 kmax = _k_max (num , den , real_break , k_break )
177+ print (kmax )
177178 kvect = np .hstack ((np .linspace (0 , kmax , 50 ), np .real (k_break )))
178179 kvect .sort ()
179180
@@ -242,16 +243,14 @@ def _default_gains(num, den, xlim, ylim,zoom_xlim=None,zoom_ylim=None):
242243def _indexes_filt (mymat ,tolerance ,zoom_xlim = None ,zoom_ylim = None ):
243244 """Calculate the distance between points and return the indexes.
244245 Filter the indexes so only the resolution of points within the xlim and ylim is improved when zoom is used"""
245-
246246 distance_points = np .abs (np .diff (mymat , axis = 0 ))
247247 indexes_too_far = list (np .unique (np .where (distance_points > tolerance )[0 ]))
248248
249249 if zoom_xlim != None and zoom_ylim != None :
250250 x_tolerance_zoom = 0.05 * (zoom_xlim [1 ] - zoom_xlim [0 ])
251251 y_tolerance_zoom = 0.05 * (zoom_ylim [1 ] - zoom_ylim [0 ])
252252 tolerance_zoom = np .min ([x_tolerance_zoom , y_tolerance_zoom ])
253- distance_points_zoom_ = np .abs (np .diff (mymat , axis = 0 ))
254- indexes_too_far_zoom = list (np .unique (np .where (distance_points_zoom_ > tolerance_zoom )[0 ]))
253+ indexes_too_far_zoom = list (np .unique (np .where (distance_points > tolerance_zoom )[0 ]))
255254 indexes_too_far_filtered = []
256255
257256 for index in indexes_too_far_zoom :
@@ -270,8 +269,8 @@ def _indexes_filt(mymat,tolerance,zoom_xlim=None,zoom_ylim=None):
270269 asign = np .sign (imag (mymat ) - limit )
271270 signchange = ((np .roll (asign , 1 , axis = 0 ) - asign ) != 0 ).astype (int )
272271 signchange [0 ] = np .zeros ((len (mymat [0 ])))
273- if len (np .where (signchange == 1 )) > 0 :
274- indexes_too_far_filtered .append (np .where (signchange == 1 )[0 ][0 ])
272+ if len (np .where (signchange == 1 )[ 0 ] ) > 0 :
273+ indexes_too_far_filtered .append (np .where (signchange == 1 )[0 ][0 ]- 1 )
275274
276275 if len (indexes_too_far_filtered ) > 0 :
277276 if indexes_too_far_filtered [0 ] != 0 :
@@ -411,8 +410,9 @@ def _RLSortRoots(mymat):
411410
412411def _RLClickDispatcher (event ,sys ,fig ,ax_rlocus ,plotstr ,sisotool = False ,bode_plot_params = None ,tvect = None ):
413412 """Rootlocus plot click dispatcher"""
413+
414414 # If zoom is used on the rootlocus plot smooth and update it
415- if plt .get_current_fig_manager ().toolbar .mode == 'zoom rect' and event .inaxes == ax_rlocus .axes :
415+ if plt .get_current_fig_manager ().toolbar .mode in [ 'zoom rect' , 'pan/zoom' ] and event .inaxes == ax_rlocus .axes :
416416
417417 (nump , denp ) = _systopoly1d (sys )
418418 xlim ,ylim = ax_rlocus .get_xlim (),ax_rlocus .get_ylim ()
@@ -446,7 +446,13 @@ def _RLFeedbackClicksPoint(event,sys,fig,ax_rlocus,sisotool=False):
446446 except TypeError :
447447 K = float ('inf' )
448448
449- if abs (K .real ) > 1e-8 and abs (K .imag / K .real ) < 0.04 and event .inaxes == ax_rlocus .axes :
449+ xlim = ax_rlocus .get_xlim ()
450+ ylim = ax_rlocus .get_ylim ()
451+ x_tolerance = 0.05 * (xlim [1 ] - xlim [0 ])
452+ y_tolerance = 0.05 * (ylim [1 ] - ylim [0 ])
453+ gain_tolerance = np .min ([x_tolerance , y_tolerance ])* 1e-1
454+
455+ if abs (K .real ) > 1e-8 and abs (K .imag / K .real ) < gain_tolerance and event .inaxes == ax_rlocus .axes :
450456
451457 # Display the parameters in the output window and figure
452458 print ("Clicked at %10.4g%+10.4gj gain %10.4g damp %10.4g" %
0 commit comments