Nyquist Plot Visualization

This module provides the Nyquist class for creating Nyquist plot visualizations of control systems.

Nyquist Class

class Nyquist(system, freq_range=None, x_range=None, y_range=None, color=ManimColor('#58C4DD'), stroke_width=2, axis_dashed=True, y_axis_label='\\mathrm{Im}', x_axis_label='\\mathrm{Re}', font_size_labels=20, show_unit_circle=False, unit_circle_dashed=False, circle_color=ManimColor('#FC6255'), show_minus_one_label=False, show_minus_one_marker=True, show_positive_freq=True, show_negative_freq=True, y_length=6, x_length=9, **kwargs)[source]

Bases: VGroup

__init__(system, freq_range=None, x_range=None, y_range=None, color=ManimColor('#58C4DD'), stroke_width=2, axis_dashed=True, y_axis_label='\\mathrm{Im}', x_axis_label='\\mathrm{Re}', font_size_labels=20, show_unit_circle=False, unit_circle_dashed=False, circle_color=ManimColor('#FC6255'), show_minus_one_label=False, show_minus_one_marker=True, show_positive_freq=True, show_negative_freq=True, y_length=6, x_length=9, **kwargs)[source]

Generates a Nyquist plot visualization as a Manim VGroup

The Nyquist plot displays the frequency response of a system in the complex plane by plotting the real and imaginary parts of the transfer function evaluated along the imaginary axis (s = jω). This visualization includes critical stability analysis features like the (-1,0) point, gain/phase margins, and optional unit circle reference.

Parameters:
  • system (various) – System representation, which can be one of: - scipy.signal.lti or transfer function coefficients (list/tuple of arrays) - Symbolic expressions for numerator/denominator (using ‘s’ as variable) - Tuple of (numerator_expr, denominator_expr) as strings or sympy expressions

  • freq_range (tuple[float] | None) – Frequency range in rad/s as (min_freq, max_freq). If None, automatically determined.

  • x_range (tuple[float] | None) – Real axis range as (min_x, max_x). If None, automatically determined.

  • y_range (tuple[float] | None) – Imaginary axis range as (min_y, max_y). If None, automatically determined.

  • color (str) – Color of the Nyquist plot curve (default: BLUE).

  • stroke_width (float) – Stroke width of the plot curve (default: 2).

  • axis_dashed (bool) – Whether to have the axis lines dashed or not

  • y_axis_label (str) – Label for the imaginary axis (default: “Im”).

  • x_axis_label (str) – Label for the real axis (default: “Re”).

  • font_size_labels (int) – Font size for axis labels (default: 20).

  • show_unit_circle (bool) – Whether to display the unit circle reference (default: False).

  • unit_circle_dashed (bool) – Whether to render unit circle as dashed (default: True).

  • circle_color (str) – Color of the unit circle (default: RED).

  • show_minus_one_label (bool) – Whether to show “-1” label at critical point (default: False).

  • show_minus_one_marker (bool) – Whether to mark the (-1,0) stability point (default: True).

  • show_positive_freq (bool) – Whether to plot positive frequency response (default: True).

  • show_negative_freq (bool) – Whether to plot negative frequency response (default: True).

  • y_length (float) – The vertical length of the plot in Manim units

  • x_length (float) – The horizonatal length of the plot in Manim units

  • **kwargs (Any) – Additional keyword arguments passed to the VGroup constructor.

Returns:

A Manim VGroup containing: - Complex plane with real and imaginary axes - Nyquist plot curve with directional arrows - Optional unit circle reference - (-1,0) critical point marker - Axis labels and ticks - Stability margin indicators (via show_margins() method)

Return type:

VGroup

grid_on()[source]

Turn on the grid lines.

grid_off()[source]

Turn off the grid lines.

title(text, font_size=30, color=ManimColor('#FFFFFF'), use_math_tex=False)[source]

Add a title to the Nyquist plot.

Parameters: - text: The title text (string) - font_size: Font size (default: 30) - use_math_tex: Whether to render as MathTex (default: False)

highlight_critical_points()[source]

Highlight critical points like (-1,0) and phase/gain margins.

show_margins(pm_color=ManimColor('#F7D96F'), mm_color=ManimColor('#FF862F'), gm_color=ManimColor('#699C52'), font_size=18, show_pm=True, show_gm=True, show_mm=True, pm_label=None, gm_label=None, mm_label=None, add_directly=True)[source]

Add visual indicators for phase and gain margins.

__init__(system, freq_range=None, x_range=None, y_range=None, color=ManimColor('#58C4DD'), stroke_width=2, axis_dashed=True, y_axis_label='\\mathrm{Im}', x_axis_label='\\mathrm{Re}', font_size_labels=20, show_unit_circle=False, unit_circle_dashed=False, circle_color=ManimColor('#FC6255'), show_minus_one_label=False, show_minus_one_marker=True, show_positive_freq=True, show_negative_freq=True, y_length=6, x_length=9, **kwargs)[source]

Generates a Nyquist plot visualization as a Manim VGroup

The Nyquist plot displays the frequency response of a system in the complex plane by plotting the real and imaginary parts of the transfer function evaluated along the imaginary axis (s = jω). This visualization includes critical stability analysis features like the (-1,0) point, gain/phase margins, and optional unit circle reference.

Parameters:
  • system (various) – System representation, which can be one of: - scipy.signal.lti or transfer function coefficients (list/tuple of arrays) - Symbolic expressions for numerator/denominator (using ‘s’ as variable) - Tuple of (numerator_expr, denominator_expr) as strings or sympy expressions

  • freq_range (tuple[float] | None) – Frequency range in rad/s as (min_freq, max_freq). If None, automatically determined.

  • x_range (tuple[float] | None) – Real axis range as (min_x, max_x). If None, automatically determined.

  • y_range (tuple[float] | None) – Imaginary axis range as (min_y, max_y). If None, automatically determined.

  • color (str) – Color of the Nyquist plot curve (default: BLUE).

  • stroke_width (float) – Stroke width of the plot curve (default: 2).

  • axis_dashed (bool) – Whether to have the axis lines dashed or not

  • y_axis_label (str) – Label for the imaginary axis (default: “Im”).

  • x_axis_label (str) – Label for the real axis (default: “Re”).

  • font_size_labels (int) – Font size for axis labels (default: 20).

  • show_unit_circle (bool) – Whether to display the unit circle reference (default: False).

  • unit_circle_dashed (bool) – Whether to render unit circle as dashed (default: True).

  • circle_color (str) – Color of the unit circle (default: RED).

  • show_minus_one_label (bool) – Whether to show “-1” label at critical point (default: False).

  • show_minus_one_marker (bool) – Whether to mark the (-1,0) stability point (default: True).

  • show_positive_freq (bool) – Whether to plot positive frequency response (default: True).

  • show_negative_freq (bool) – Whether to plot negative frequency response (default: True).

  • y_length (float) – The vertical length of the plot in Manim units

  • x_length (float) – The horizonatal length of the plot in Manim units

  • **kwargs (Any) – Additional keyword arguments passed to the VGroup constructor.

Returns:

A Manim VGroup containing: - Complex plane with real and imaginary axes - Nyquist plot curve with directional arrows - Optional unit circle reference - (-1,0) critical point marker - Axis labels and ticks - Stability margin indicators (via show_margins() method)

Return type:

VGroup

animation_overrides = {}
background_image: Image | str | None
background_stroke_color: ManimColor
background_stroke_opacity: float
background_stroke_width: float
cap_style: CapStyleType
close_new_points: bool
grid_off()[source]

Turn off the grid lines.

grid_on()[source]

Turn on the grid lines.

highlight_critical_points()[source]

Highlight critical points like (-1,0) and phase/gain margins.

joint_type: LineJointType
make_smooth_after_applying_functions: bool
n_points_per_cubic_curve: int
pre_function_handle_to_anchor_scale_factor: float
shade_in_3d: bool
show_margins(pm_color=ManimColor('#F7D96F'), mm_color=ManimColor('#FF862F'), gm_color=ManimColor('#699C52'), font_size=18, show_pm=True, show_gm=True, show_mm=True, pm_label=None, gm_label=None, mm_label=None, add_directly=True)[source]

Add visual indicators for phase and gain margins.

submobjects: list[VMobject]
title(text, font_size=30, color=ManimColor('#FFFFFF'), use_math_tex=False)[source]

Add a title to the Nyquist plot.

Parameters: - text: The title text (string) - font_size: Font size (default: 30) - use_math_tex: Whether to render as MathTex (default: False)

tolerance_for_point_equality: float

System Input Formats

The Nyquist class accepts multiple system representation formats:

  1. Scipy LTI objects: signal.TransferFunction, signal.ZerosPolesGain, signal.StateSpace

  2. Coefficient tuples: (numerator_coeffs, denominator_coeffs)

  3. Symbolic expressions: Strings or sympy expressions using ‘s’ as variable

  4. Transfer function strings: "s/(s^2 + 1)" or "s/(s^2 + 1)/1"

Plot Features

  • Automatic range determination based on system poles and zeros

  • Unit circle reference for stability analysis

  • (-1,0) critical point marking with optional label

  • Positive and negative frequency response plotting

  • Gain margin, phase margin, and modulus margin visualization

  • Directional arrows indicating frequency sweep direction

  • Customizable grid with dB and phase reference lines

Stability Analysis

The Nyquist plot provides visual indicators for:

  • Gain Margin (GM): Distance from (-1,0) along the real axis

  • Phase Margin (PM): Angle from negative real axis to unity gain point

  • Modulus Margin (MM): Minimum distance from (-1,0) to Nyquist curve

  • Critical (-1,0) point: Stability boundary reference

Notes

  • Internal methods (starting with _) are not intended for user use

  • The class automatically handles range determination and axis scaling

  • Grid lines include both constant magnitude (dB) and constant phase references

  • Arrows indicate the direction of increasing frequency

  • Special handling for systems with poles at the origin (integrators)