Refine automatic contour determination in Nyquist plot by bnavigator · Pull Request #620 · python-control/python-control
import control
import matplotlib.pyplot as plt
G = control.tf([1], [1,1,0,0,0])
count, contour1 = control.nyquist_plot(G, label='indent_radius default (0.1)',
return_contour=True)
R = 0.11
count, contour2 = control.nyquist_plot(G, indent_radius=R,
return_contour=True,
label=f'indent_radius={R}')
ax = plt.gca()
ax.set_aspect(1)
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)
plt.figure()
cp = plt.plot(contour1.real, contour1.imag, '-',
label='indent_radius default (0.1)')
c = cp[0].get_color()
plt.plot(contour1.real, -contour1.imag, '--', color=c)
cp = plt.plot(contour2.real, contour2.imag, '-',
label=f'indent_radius={R}')
c = cp[0].get_color()
plt.plot(contour2.real, -contour2.imag, '--', color=c)
ax = plt.gca()
ax.legend()
ax.set_aspect(1)
ax.set_xlim([-0.2, 0.2])
ax.set_ylim([-0.2, 0.2])
ax.grid()
ax.set_title(r'Nyquist Contour $\Gamma$',)
plt.show()