@@ -1477,8 +1477,8 @@ def nyquist_response(
14771477
14781478def nyquist_plot (
14791479 data , omega = None , plot = None , label_freq = 0 , color = None , label = None ,
1480- return_contour = None , title = None , legend_loc = 'upper right' ,
1481- ax = None , ** kwargs ):
1480+ return_contour = None , title = None , legend_loc = 'upper right' , ax = None ,
1481+ unit_circle = False , mt_circles = None , ms_circles = None , ** kwargs ):
14821482 """Nyquist plot for a system.
14831483
14841484 Generates a Nyquist plot for the system over a (optional) frequency
@@ -1501,7 +1501,13 @@ def nyquist_plot(
15011501 ``omega_limits``.
15021502 color : string, optional
15031503 Used to specify the color of the line and arrowhead.
1504-
1504+ unit_circle : bool, optional
1505+ If ``True``, display the unit circle, to read gain crossover frequency.
1506+ mt_circles : array_like, optional
1507+ Draws circles corresponding to the given magnitudes of sensitivity.
1508+ ms_circles : array_like, optional
1509+ Draws circles corresponding to the given magnitudes in complementary
1510+ sensitivity.
15051511 **kwargs : :func:`matplotlib.pyplot.plot` keyword properties, optional
15061512 Additional keywords (passed to `matplotlib`)
15071513
@@ -1856,6 +1862,27 @@ def _parse_linestyle(style_name, allow_false=False):
18561862 # Mark the -1 point
18571863 plt .plot ([- 1 ], [0 ], 'r+' )
18581864
1865+ theta = np .linspace (0 , 2 * np .pi , 100 )
1866+ cos = np .cos (theta )
1867+ sin = np .sin (theta )
1868+
1869+ if unit_circle :
1870+ plt .plot (cos , sin , color = "black" , linestyle = 'dashed' , linewidth = 1 )
1871+
1872+ if ms_circles is not None :
1873+ for ms in ms_circles :
1874+ plt .plot (- 1 + (1 / ms )* cos , (1 / ms )* sin , color = "black" , linestyle = "dashed" , linewidth = 1 )
1875+
1876+ if mt_circles is not None :
1877+ for mt in mt_circles :
1878+ if mt != 1 :
1879+ ct = - mt ** 2 / (mt ** 2 - 1 ) # Mt center
1880+ rt = mt / (mt ** 2 - 1 ) # Mt radius
1881+ plt .plot (ct + rt * cos , rt * sin , color = "black" , linestyle = "dashed" , linewidth = 1 )
1882+ else :
1883+ _ , _ , ymin , ymax = plt .axis ()
1884+ plt .vlines (- 0.5 , ymin = ymin , ymax = ymax , colors = "black" , linestyles = "dashed" , linewidth = 1 )
1885+
18591886 # Label the frequencies of the points
18601887 if label_freq :
18611888 ind = slice (None , None , label_freq )
0 commit comments