@@ -122,9 +122,12 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None, plotstr='-', Plot=True,
122122 ax , f = nogrid ()
123123 pylab .title (new_figure_name )
124124
125+ ax = pylab .axes ()
126+
125127 if PrintGain :
128+ click_point , = ax .plot ([0 ], [0 ],color = 'k' ,markersize = 0 ,marker = 's' ,zorder = 20 )
126129 f .canvas .mpl_connect (
127- 'button_release_event' , partial (_RLFeedbackClicks , sys = sys ))
130+ 'button_release_event' , partial (_RLFeedbackClicks , sys = sys , fig = f , point = click_point ))
128131
129132 # plot open loop poles
130133 poles = array (denp .r )
@@ -157,6 +160,7 @@ def _default_gains(num, den, xlim, ylim):
157160 kmax = _k_max (num , den , real_break , k_break )
158161 kvect = np .hstack ((np .linspace (0 , kmax , 50 ), np .real (k_break )))
159162 kvect .sort ()
163+
160164 mymat = _RLFindRoots (num , den , kvect )
161165 mymat = _RLSortRoots (mymat )
162166 open_loop_poles = den .roots
@@ -346,13 +350,19 @@ def _RLSortRoots(mymat):
346350 return sorted
347351
348352
349- def _RLFeedbackClicks (event , sys ):
353+ def _RLFeedbackClicks (event , sys , fig , point ):
350354 """Print root-locus gain feedback for clicks on the root-locus plot
351355 """
352356 s = complex (event .xdata , event .ydata )
353357 K = - 1. / sys .horner (s )
354358 if abs (K .real ) > 1e-8 and abs (K .imag / K .real ) < 0.04 :
355359 print ("Clicked at %10.4g%+10.4gj gain %10.4g damp %10.4g" %
356360 (s .real , s .imag , K .real , - 1 * s .real / abs (s )))
361+ point .set_ydata (s .imag )
362+ point .set_xdata (s .real )
363+ point .set_markersize (8 )
364+ fig .suptitle ("Clicked at: %10.4g%+10.4gj gain: %10.4g damp: %10.4g" %
365+ (s .real , s .imag , K .real , - 1 * s .real / abs (s )))
366+ fig .canvas .draw ()
357367
358368rlocus = root_locus
0 commit comments