control.nyquist_plot
- control.nyquist_plot(data, omega=None, plot=None, label_freq=0, color=None, label=None, return_contour=None, title=None, ax=None, unit_circle=False, mt_circles=None, ms_circles=None, **kwargs)[source]
Nyquist plot for a system.
Generates a Nyquist plot for the system over a (optional) frequency range. The curve is computed by evaluating the Nyqist segment along the positive imaginary axis, with a mirror image generated to reflect the negative imaginary axis. Poles on or near the imaginary axis are avoided using a small indentation. The portion of the Nyquist contour at infinity is not explicitly computed (since it maps to a constant value for any system with a proper transfer function).
- Parameters
data (list of LTI or NyquistResponseData) – List of linear input/output systems (single system is OK) or Nyquist ersponses (computed using
nyquist_response()
). Nyquist curves for each system are plotted on the same graph.omega (array_like, optional) – Set of frequencies to be evaluated, in rad/sec. Specifying
omega
as a list of two elements is equivalent to providingomega_limits
.unit_circle (bool, optional) – If
True
, display the unit circle, to read gain crossover frequency.mt_circles (array_like, optional) – Draw circles corresponding to the given magnitudes of sensitivity.
ms_circles (array_like, optional) – Draw circles corresponding to the given magnitudes of complementary sensitivity.
**kwargs (
matplotlib.pyplot.plot()
keyword properties, optional) – Additional keywords passed to matplotlib to specify line properties.arrows (int or 1D/2D array of floats, optional) – Specify the number of arrows to plot on the Nyquist curve. If an integer is passed. that number of equally spaced arrows will be plotted on each of the primary segment and the mirror image. If a 1D array is passed, it should consist of a sorted list of floats between 0 and 1, indicating the location along the curve to plot an arrow. If a 2D array is passed, the first row will be used to specify arrow locations for the primary curve and the second row will be used for the mirror image.
arrow_size (float, optional) – Arrowhead width and length (in display coordinates). Default value is 8 and can be set using config.defaults[‘nyquist.arrow_size’].
arrow_style (matplotlib.patches.ArrowStyle, optional) – Define style used for Nyquist curve arrows (overrides arrow_size).
ax (matplotlib.axes.Axes, optional) – The matplotlib axes to draw the figure on. If not specified and the current figure has a single axes, that axes is used. Otherwise, a new figure is created.
encirclement_threshold (float, optional) – Define the threshold for generating a warning if the number of net encirclements is a non-integer value. Default value is 0.05 and can be set using config.defaults[‘nyquist.encirclement_threshold’].
indent_direction (str, optional) – For poles on the imaginary axis, set the direction of indentation to be ‘right’ (default), ‘left’, or ‘none’.
indent_points (int, optional) – Number of points to insert in the Nyquist contour around poles that are at or near the imaginary axis.
indent_radius (float, optional) – Amount to indent the Nyquist contour around poles on or near the imaginary axis. Portions of the Nyquist plot corresponding to indented portions of the contour are plotted using a different line style.
label (str or array_like of str, optional) – If present, replace automatically generated label(s) with the given label(s). If sysdata is a list, strings should be specified for each system.
label_freq (int, optiona) – Label every nth frequency on the plot. If not specified, no labels are generated.
legend_loc (int or str, optional) – Include a legend in the given location. Default is ‘upper right’, with no legend for a single response. Use False to suppress legend.
max_curve_magnitude (float, optional) – Restrict the maximum magnitude of the Nyquist plot to this value. Portions of the Nyquist plot whose magnitude is restricted are plotted using a different line style.
max_curve_offset (float, optional) – When plotting scaled portion of the Nyquist plot, increase/decrease the magnitude by this fraction of the max_curve_magnitude to allow any overlaps between the primary and mirror curves to be avoided.
mirror_style ([str, str] or False) – Linestyles for mirror image of the Nyquist curve. The first element is used for unscaled portions of the Nyquist curve, the second element is used for portions that are scaled (using max_curve_magnitude). If False then omit completely. Default linestyle ([‘–’, ‘:’]) is determined by config.defaults[‘nyquist.mirror_style’].
omega_limits (array_like of two values) – Set limits for plotted frequency range. If Hz=True the limits are in Hz otherwise in rad/s. Specifying
omega
as a list of two elements is equivalent to providingomega_limits
.omega_num (int, optional) – Number of samples to use for the frequeny range. Defaults to config.defaults[‘freqplot.number_of_samples’]. Ignored if data is not a list of systems.
plot (bool, optional) – (legacy) If given, nyquist_plot returns the legacy return values of (counts, contours). If False, return the values with no plot.
primary_style ([str, str], optional) – Linestyles for primary image of the Nyquist curve. The first element is used for unscaled portions of the Nyquist curve, the second element is used for portions that are scaled (using max_curve_magnitude). Default linestyle ([‘-‘, ‘-.’]) is determined by config.defaults[‘nyquist.mirror_style’].
rcParams (dict) – Override the default parameters used for generating plots. Default is set by config.default[‘ctrlplot.rcParams’].
return_contour (bool, optional) – (legacy) If ‘True’, return the encirclement count and Nyquist contour used to generate the Nyquist plot.
show_legend (bool, optional) – Force legend to be shown if
True
or hidden ifFalse
. IfNone
, then show legend when there is more than one line on the plot orlegend_loc
has been specified.start_marker (str, optional) – Matplotlib marker to use to mark the starting point of the Nyquist plot. Defaults value is ‘o’ and can be set using config.defaults[‘nyquist.start_marker’].
start_marker_size (float, optional) – Start marker size (in display coordinates). Default value is 4 and can be set using config.defaults[‘nyquist.start_marker_size’].
title (str, optional) – Set the title of the plot. Defaults to plot type and system name(s).
title_frame (str, optional) – Set the frame of reference used to center the plot title. If set to ‘axes’ (default), the horizontal position of the title will centered relative to the axes. If set to ‘figure’, it will be centered with respect to the figure (faster execution).
warn_nyquist (bool, optional) – If set to ‘False’, turn off warnings about frequencies above Nyquist.
warn_encirclements (bool, optional) – If set to ‘False’, turn off warnings about number of encirclements not meeting the Nyquist criterion.
- Returns
cplt –
Object containing the data that were plotted:
cplt.lines: 2D array of
matplotlib.lines.Line2D
objects for each line in the plot. The shape of the array is given by (nsys, 4) where nsys is the number of systems or Nyquist responses passed to the function. The second index specifies the segment type:lines[idx, 0]: unscaled portion of the primary curve
lines[idx, 1]: scaled portion of the primary curve
lines[idx, 2]: unscaled portion of the mirror curve
lines[idx, 3]: scaled portion of the mirror curve
cplt.axes: 2D array of
matplotlib.axes.Axes
for the plot.cplt.figure:
matplotlib.figure.Figure
containing the plot.cplt.legend: legend object(s) contained in the plot
See
ControlPlot
for more detailed information.- Return type
ControlPlot
object
See also
Notes
If a discrete time model is given, the frequency response is computed along the upper branch of the unit circle, using the mapping
z = exp(1j * omega * dt)
where omega ranges from 0 to pi/dt and dt is the discrete timebase. If timebase not specified (dt=True
), dt is set to 1.If a continuous-time system contains poles on or near the imaginary axis, a small indentation will be used to avoid the pole. The radius of the indentation is given by indent_radius and it is taken to the right of stable poles and the left of unstable poles. If a pole is exactly on the imaginary axis, the indent_direction parameter can be used to set the direction of indentation. Setting indent_direction to none will turn off indentation. If return_contour is True, the exact contour used for evaluation is returned.
For those portions of the Nyquist plot in which the contour is indented to avoid poles, resuling in a scaling of the Nyquist plot, the line styles are according to the settings of the primary_style and mirror_style keywords. By default the scaled portions of the primary curve use a dotted line style and the scaled portion of the mirror image use a dashdot line style.
Examples
>>> G = ct.zpk([], [-1, -2, -3], gain=100) >>> out = ct.nyquist_plot(G)