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
18631865plt.plot([-1], [0], 'r+')
1864-1866+1867+#
1868+# Draw circles for gain crossover and sensitivity functions
1869+#
18651870theta = np.linspace(0, 2*np.pi, 100)
18661871cos = np.cos(theta)
18671872sin = np.sin(theta)
18681873label_pos = 15
186918741875+# Display the unit circle, to read gain crossover frequency
18701876if 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
18731880if ms_circles is not None:
18741881for ms in ms_circles:
18751882pos_x = -1 + (1/ms)*cos
18761883pos_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'])
18781886plt.text(pos_x[label_pos], pos_y[label_pos], ms)
187918871888+# Draw circles for given magnitudes of complementary sensitivity
18801889if mt_circles is not None:
18811890for mt in mt_circles:
18821891if mt != 1:
18831892ct = -mt**2/(mt**2-1) # Mt center
18841893rt = mt/(mt**2-1) # Mt radius
18851894pos_x = ct+rt*cos
18861895pos_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'])
18881899plt.text(pos_x[label_pos], pos_y[label_pos], mt)
18891900else:
18901901_, _, ymin, ymax = plt.axis()
18911902pos_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'])
18931906plt.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
18961909if label_freq:
18971910ind = slice(None, None, label_freq)
18981911omega_sys = np.imag(splane_contour[np.real(splane_contour) == 0])