- Notifications
You must be signed in to change notification settings - Fork441
Closed
Labels
Description
I 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 theax
parameter of therlocus
function:
from control import *import matplotlib.pyplot as plts = 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