I'm having problems with the `ax` parameters of the `rlocus` function
See original GitHub issueI was trying today to plot the root locus of a transfer function, but wanted to pass a specific axes object to it, so I tried to use the ax parameter of the rlocus function:
from control import *
import matplotlib.pyplot as plt
s = tf([1, 0], 1)
G = 1/(s*(s+1))
fig, ax = plt.subplots(dpi=200)
rlocus(G, ax=ax)
But when doing this, the following error was raised:
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-1-80498c4b1a54> in <module>
6
7 fig, ax = plt.subplots(dpi=200)
----> 8 rlocus(G, ax=ax)
~\anaconda3\lib\site-packages\control\rlocus.py in root_locus(sys, kvect, xlim, ylim, plotstr, plot, print_gain, grid, ax, **kwargs)
173
174 if print_gain and not sisotool:
--> 175 fig.canvas.mpl_connect(
176 'button_release_event',
177 partial(_RLClickDispatcher, sys=sys, fig=fig,
UnboundLocalError: local variable 'fig' referenced before assignment
Control version: 0.9.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Root locus plot of dynamic system - MATLAB rlocus - MathWorks
This MATLAB function calculates and plots the root locus of the SISO model sys.
Read more >10.6: Root Locus Plots - Effect of Tuning
Root locus plots show the roots of the systems characteristic equation, (i.e. the Laplacian), as a function of the control variables such as ......
Read more >Root locus in control system - YouTube
Root Locus Problems | Root locus in control system| Root Locus Questions| Control system. 7.2K views 2 years ago. Easy Electronics.
Read more >Using 'rlocus' in Matlab to Plot the Root Locus - YouTube
This tutorial illustrates how to use the ' rlocus ' command in Matlab to quickly and easily ... Discussion on the 3 example...
Read more >CDS 101: Lecture 9.2 PID and Root Locus
Describe root locus diagram and show how to use it to choose loop gain ... Can plot pole location versus any parameter; just...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ll have a look at #634. But I’m waiting for further input on the new plotting paradigm. That will require more thinking and discussion and probably take a while to figure out a way forward. There might be better ways to do it. I’m happy to try fixing the immediate bugs on the existing functions when I next get the chance.
I’m happy to implement this immediate fix (and #632 at the same time) and maybe add some unit tests, including for other plot functions where applicable. If I recall correctly, I was trying to do this a while back and the problem is that some plot funcs need to generate their own axis (e.g. radial plots) and some generate a figure containing more than one axis.