Skip to content

PyDynSys.vis Module

Full Docs

PyDynSys.vis

Visualization utilities for PyDynSys.

plot_phase_space(phase_space, xlim, ylim, resolution=200, ax=None, **kwargs)

Visualize a PhaseSpace using its constraint function.

This is a general entry point for PhaseSpace visualization. Currently only 2D phase spaces are supported via plot_planar_phase_space.

Parameters:

Name Type Description Default
phase_space PhaseSpace

The PhaseSpace to visualize

required
xlim Tuple[float, float]

Tuple (x_min, x_max) for plot bounds

required
ylim Tuple[float, float]

Tuple (y_min, y_max) for plot bounds

required
resolution int

Number of grid points per dimension (default: 200)

200
ax Optional[Axes]

Optional matplotlib Axes to plot on. If None, creates a new figure

None
**kwargs Any

Additional arguments passed to matplotlib's imshow function

{}

Returns:

Type Description
Axes

matplotlib.axes.Axes: The matplotlib Axes object containing the plot

Raises:

Type Description
NotImplementedError

If phase_space.dimension != 2

Source code in src/PyDynSys/vis/euclidean/phase_space.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def plot_phase_space(
    phase_space: PhaseSpace,
    xlim: Tuple[float, float],
    ylim: Tuple[float, float],
    resolution: int = 200,
    ax: Optional[Axes] = None,
    **kwargs
) -> Axes:
    """
    Visualize a PhaseSpace using its constraint function.

    This is a general entry point for PhaseSpace visualization. Currently only
    2D phase spaces are supported via plot_planar_phase_space.

    Args:
        phase_space (core.euclidean.PhaseSpace): The PhaseSpace to visualize
        xlim (Tuple[float, float]): Tuple (x_min, x_max) for plot bounds
        ylim (Tuple[float, float]): Tuple (y_min, y_max) for plot bounds
        resolution (int): Number of grid points per dimension (default: 200)
        ax (Optional[matplotlib.axes.Axes]): Optional matplotlib Axes to plot on. If None, creates a new figure
        **kwargs (Any): Additional arguments passed to matplotlib's imshow function

    Returns:
        matplotlib.axes.Axes: The matplotlib Axes object containing the plot

    Raises:
        NotImplementedError: If phase_space.dimension != 2
    """
    if phase_space.dimension == 2:
        return plot_planar_phase_space(
            phase_space=phase_space,
            xlim=xlim,
            ylim=ylim,
            resolution=resolution,
            ax=ax,
            **kwargs
        )
    else:
        raise NotImplementedError(
            f"plot_phase_space only supports 2D PhaseSpaces currently, "
            f"got dimension {phase_space.dimension}. "
            f"Support for dimensions != 2 is planned for future releases."
        )