7676# Main function: compute a root locus diagram
7777def root_locus (sys , kvect = None , xlim = None , ylim = None ,
7878 plotstr = None , plot = True , print_gain = None , grid = None , ax = None ,
79- ** kwargs ):
79+ zeta = None , linewidth = None , ** kwargs ):
8080
8181 """Root locus plot
8282
@@ -199,7 +199,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
199199 # zoom update on xlim/ylim changed, only then data on new limits
200200 # is available, i.e., cannot combine with _RLClickDispatcher
201201 dpfun = partial (
202- _RLZoomDispatcher , sys = sys , ax_rlocus = ax , plotstr = plotstr )
202+ _RLZoomDispatcher , sys = sys , ax_rlocus = ax , plotstr = plotstr , linewidth = linewidth )
203203 # TODO: the next too lines seem to take a long time to execute
204204 # TODO: is there a way to speed them up? (RMM, 6 Jun 2019)
205205 ax .callbacks .connect ('xlim_changed' , dpfun )
@@ -216,7 +216,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
216216
217217 # Now plot the loci
218218 for index , col in enumerate (mymat .T ):
219- ax .plot (real (col ), imag (col ), plotstr , label = 'rootlocus' )
219+ ax .plot (real (col ), imag (col ), plotstr , label = 'rootlocus' , linewidth = linewidth )
220220
221221 # Set up plot axes and labels
222222 ax .set_xlabel ('Real' )
@@ -226,12 +226,12 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
226226 if isdtime (sys , strict = True ):
227227 zgrid (ax = ax )
228228 else :
229- _sgrid_func (f )
229+ _sgrid_func (ax )
230230 elif grid :
231231 if isdtime (sys , strict = True ):
232232 zgrid (ax = ax )
233233 else :
234- _sgrid_func ()
234+ _sgrid_func (ax = ax , zeta = zeta )
235235 else :
236236 ax .axhline (0. , linestyle = ':' , color = 'k' , zorder = - 20 )
237237 ax .axvline (0. , linestyle = ':' , color = 'k' , zorder = - 20 )
@@ -535,7 +535,7 @@ def _RLSortRoots(mymat):
535535 return sorted
536536
537537
538- def _RLZoomDispatcher (event , sys , ax_rlocus , plotstr ):
538+ def _RLZoomDispatcher (event , sys , ax_rlocus , plotstr , linewidth = None ):
539539 """Rootlocus plot zoom dispatcher"""
540540
541541 nump , denp = _systopoly1d (sys )
@@ -546,7 +546,7 @@ def _RLZoomDispatcher(event, sys, ax_rlocus, plotstr):
546546 _removeLine ('rootlocus' , ax_rlocus )
547547
548548 for i , col in enumerate (mymat .T ):
549- ax_rlocus .plot (real (col ), imag (col ), plotstr , label = 'rootlocus' ,
549+ ax_rlocus .plot (real (col ), imag (col ), plotstr , label = 'rootlocus' , linewidth = linewidth ,
550550 scalex = False , scaley = False )
551551
552552
@@ -636,12 +636,13 @@ def _removeLine(label, ax):
636636 del line
637637
638638
639- def _sgrid_func (fig = None , zeta = None , wn = None ):
639+ def _sgrid_func (fig = None , ax = None , zeta = None , wn = None ):
640640 if fig is None :
641641 fig = plt .gcf ()
642642 ax = fig .gca ()
643- else :
643+ elif ax is None :
644644 ax = fig .axes [1 ]
645+
645646 xlocator = ax .get_xaxis ().get_major_locator ()
646647
647648 ylim = ax .get_ylim ()
@@ -683,7 +684,7 @@ def _sgrid_func(fig=None, zeta=None, wn=None):
683684 ax .plot ([0 , 0 ], [ylim [0 ], ylim [1 ]],
684685 color = 'gray' , linestyle = 'dashed' , linewidth = 0.5 )
685686
686- angles = np .linspace (- 90 , 90 , 20 )* np .pi / 180
687+ angles = np .linspace (- 90 , 90 , 200 )* np .pi / 180
687688 if wn is None :
688689 wn = _default_wn (xlocator (), ylim )
689690
0 commit comments