Skip to content

Commit decc8b8

Browse files
committed
Fixed axes ratio 'equal' when grid=None for discrete rlocus
1 parent fcc9a56 commit decc8b8

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

control/grid.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,12 @@ def _final_setup(ax):
151151
ax.axis('equal')
152152

153153

154-
def nogrid():
155-
# TODO: this doesn't look safe. convert to take ax argument
156-
f = plt.gcf()
157-
ax = plt.axes()
158-
154+
def nogrid(ax=None):
155+
if ax is None:
156+
ax = plt.gca()
157+
fig = ax.figure
159158
_final_setup(ax)
160-
return ax, f
159+
return ax, fig
161160

162161

163162
def zgrid(zetas=None, wns=None, ax=None):

control/rlocus.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
from .xferfcn import _convert_to_transfer_function
6060
from .exception import ControlMIMONotImplemented
6161
from .sisotool import _SisotoolUpdate
62-
from .grid import sgrid, zgrid
62+
from .grid import sgrid, zgrid, nogrid
6363
from . import config
6464

6565
__all__ = ['root_locus', 'rlocus']
@@ -220,27 +220,31 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None, plotstr=None,
220220
for index, col in enumerate(mymat.T):
221221
ax.plot(real(col), imag(col), plotstr, label='rootlocus')
222222

223-
# Set up plot axes and labels
224-
ax.set_xlabel('Real')
225-
ax.set_ylabel('Imaginary')
226-
227223
# Draw the grid
228224
if grid:
229225
if isdtime(sys, strict=True):
230226
zgrid(ax=ax)
231227
else:
232228
_sgrid_func(fig=fig if sisotool else None)
233229
else:
230+
# TODO: could some of the settings below be done with nogrid:
231+
#nogrid(ax=ax)
232+
# nogrid calls grid._final_setup() which has slightly different
233+
# settings for axhline and axvline linewidths and no zorder
234+
# setting. For now I am leaving the original commands below:
234235
ax.axhline(0., linestyle=':', color='k', linewidth=.75, zorder=-20)
235236
ax.axvline(0., linestyle=':', color='k', linewidth=.75, zorder=-20)
236237
if isdtime(sys, strict=True):
237238
ax.add_patch(plt.Circle(
238239
(0, 0), radius=1.0, linestyle=':', edgecolor='k',
239240
linewidth=0.75, fill=False, zorder=-20))
241+
ax.set_xlabel('Real')
242+
ax.set_ylabel('Imaginary')
243+
ax.axis('equal')
240244

241245
# Set the axes limits
242-
# Note: I moved this to after computing grid lines above because
243-
# something in above was changing the xlim for discrete zgrid.
246+
# Note: I moved this to after the grid lines code above because
247+
# something in above was changing the xlim for discrete zgrids
244248
if xlim:
245249
ax.set_xlim(xlim)
246250
if ylim:

0 commit comments

Comments
 (0)