76
76
# Main function: compute a root locus diagram
77
77
def root_locus (sys , kvect = None , xlim = None , ylim = None ,
78
78
plotstr = None , plot = True , print_gain = None , grid = None , ax = None ,
79
- ** kwargs ):
79
+ zeta = None , linewidth = None , ** kwargs ):
80
80
81
81
"""Root locus plot
82
82
@@ -199,7 +199,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
199
199
# zoom update on xlim/ylim changed, only then data on new limits
200
200
# is available, i.e., cannot combine with _RLClickDispatcher
201
201
dpfun = partial (
202
- _RLZoomDispatcher , sys = sys , ax_rlocus = ax , plotstr = plotstr )
202
+ _RLZoomDispatcher , sys = sys , ax_rlocus = ax , plotstr = plotstr , linewidth = linewidth )
203
203
# TODO: the next too lines seem to take a long time to execute
204
204
# TODO: is there a way to speed them up? (RMM, 6 Jun 2019)
205
205
ax .callbacks .connect ('xlim_changed' , dpfun )
@@ -216,7 +216,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
216
216
217
217
# Now plot the loci
218
218
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 )
220
220
221
221
# Set up plot axes and labels
222
222
ax .set_xlabel ('Real' )
@@ -226,12 +226,12 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
226
226
if isdtime (sys , strict = True ):
227
227
zgrid (ax = ax )
228
228
else :
229
- _sgrid_func (f )
229
+ _sgrid_func (ax )
230
230
elif grid :
231
231
if isdtime (sys , strict = True ):
232
232
zgrid (ax = ax )
233
233
else :
234
- _sgrid_func ()
234
+ _sgrid_func (ax = ax , zeta = zeta )
235
235
else :
236
236
ax .axhline (0. , linestyle = ':' , color = 'k' , zorder = - 20 )
237
237
ax .axvline (0. , linestyle = ':' , color = 'k' , zorder = - 20 )
@@ -535,7 +535,7 @@ def _RLSortRoots(mymat):
535
535
return sorted
536
536
537
537
538
- def _RLZoomDispatcher (event , sys , ax_rlocus , plotstr ):
538
+ def _RLZoomDispatcher (event , sys , ax_rlocus , plotstr , linewidth = None ):
539
539
"""Rootlocus plot zoom dispatcher"""
540
540
541
541
nump , denp = _systopoly1d (sys )
@@ -546,7 +546,7 @@ def _RLZoomDispatcher(event, sys, ax_rlocus, plotstr):
546
546
_removeLine ('rootlocus' , ax_rlocus )
547
547
548
548
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 ,
550
550
scalex = False , scaley = False )
551
551
552
552
@@ -636,12 +636,13 @@ def _removeLine(label, ax):
636
636
del line
637
637
638
638
639
- def _sgrid_func (fig = None , zeta = None , wn = None ):
639
+ def _sgrid_func (fig = None , ax = None , zeta = None , wn = None ):
640
640
if fig is None :
641
641
fig = plt .gcf ()
642
642
ax = fig .gca ()
643
- else :
643
+ elif ax is None :
644
644
ax = fig .axes [1 ]
645
+
645
646
xlocator = ax .get_xaxis ().get_major_locator ()
646
647
647
648
ylim = ax .get_ylim ()
@@ -683,7 +684,7 @@ def _sgrid_func(fig=None, zeta=None, wn=None):
683
684
ax .plot ([0 , 0 ], [ylim [0 ], ylim [1 ]],
684
685
color = 'gray' , linestyle = 'dashed' , linewidth = 0.5 )
685
686
686
- angles = np .linspace (- 90 , 90 , 20 )* np .pi / 180
687
+ angles = np .linspace (- 90 , 90 , 200 )* np .pi / 180
687
688
if wn is None :
688
689
wn = _default_wn (xlocator (), ylim )
689
690
0 commit comments