rebase on main + allow circle styles to be set via defaults · python-control/python-control@10d2010

@@ -1060,7 +1060,9 @@ def gen_zero_centered_series(val_min, val_max, period):

10601060

'nyquist.max_curve_magnitude': 20, # clip large values

10611061

'nyquist.max_curve_offset': 0.02, # offset of primary/mirror

10621062

'nyquist.start_marker': 'o', # marker at start of curve

1063-

'nyquist.start_marker_size': 4, # size of the maker

1063+

'nyquist.start_marker_size': 4, # size of the marker

1064+

'nyquist.circle_style': # style for unit circles

1065+

{'color': 'black', 'linestyle': 'dashed', 'linewidth': 1}

10641066

}

1065106710661068

@@ -1504,9 +1506,9 @@ def nyquist_plot(

15041506

unit_circle : bool, optional

15051507

If ``True``, display the unit circle, to read gain crossover frequency.

15061508

mt_circles : array_like, optional

1507-

Draws circles corresponding to the given magnitudes of sensitivity.

1509+

Draw circles corresponding to the given magnitudes of sensitivity.

15081510

ms_circles : array_like, optional

1509-

Draws circles corresponding to the given magnitudes in complementary

1511+

Draw circles corresponding to the given magnitudes of complementary

15101512

sensitivity.

15111513

**kwargs : :func:`matplotlib.pyplot.plot` keyword properties, optional

15121514

Additional keywords (passed to `matplotlib`)

@@ -1861,38 +1863,49 @@ def _parse_linestyle(style_name, allow_false=False):

1861186318621864

# Mark the -1 point

18631865

plt.plot([-1], [0], 'r+')

1864-1866+1867+

#

1868+

# Draw circles for gain crossover and sensitivity functions

1869+

#

18651870

theta = np.linspace(0, 2*np.pi, 100)

18661871

cos = np.cos(theta)

18671872

sin = np.sin(theta)

18681873

label_pos = 15

186918741875+

# Display the unit circle, to read gain crossover frequency

18701876

if unit_circle:

1871-

plt.plot(cos, sin, color="black", linestyle='dashed', linewidth=1)

1877+

plt.plot(cos, sin, **config.defaults['nyquist.circle_style'])

187218781879+

# Draw circles for given magnitudes of sensitivity

18731880

if ms_circles is not None:

18741881

for ms in ms_circles:

18751882

pos_x = -1 + (1/ms)*cos

18761883

pos_y = (1/ms)*sin

1877-

plt.plot(pos_x, pos_y, color="black", linestyle="dashed", linewidth=1)

1884+

plt.plot(

1885+

pos_x, pos_y, **config.defaults['nyquist.circle_style'])

18781886

plt.text(pos_x[label_pos], pos_y[label_pos], ms)

187918871888+

# Draw circles for given magnitudes of complementary sensitivity

18801889

if mt_circles is not None:

18811890

for mt in mt_circles:

18821891

if mt != 1:

18831892

ct = -mt**2/(mt**2-1) # Mt center

18841893

rt = mt/(mt**2-1) # Mt radius

18851894

pos_x = ct+rt*cos

18861895

pos_y = rt*sin

1887-

plt.plot(pos_x, pos_y, color="black", linestyle="dashed", linewidth=1)

1896+

plt.plot(

1897+

pos_x, pos_y,

1898+

**config.defaults['nyquist.circle_style'])

18881899

plt.text(pos_x[label_pos], pos_y[label_pos], mt)

18891900

else:

18901901

_, _, ymin, ymax = plt.axis()

18911902

pos_y = np.linspace(ymin, ymax, 100)

1892-

plt.vlines(-0.5, ymin=ymin, ymax=ymax, colors="black", linestyles="dashed", linewidth=1)

1903+

plt.vlines(

1904+

-0.5, ymin=ymin, ymax=ymax,

1905+

**config.defaults['nyquist.circle_style'])

18931906

plt.text(-0.5, pos_y[label_pos], 1)

189419071895-

# Label the frequencies of the points

1908+

# Label the frequencies of the points on the Nyquist curve

18961909

if label_freq:

18971910

ind = slice(None, None, label_freq)

18981911

omega_sys = np.imag(splane_contour[np.real(splane_contour) == 0])