Trajectory Plots

Plotting phase-space trajectories in 2D and 3D.

The plot_overlay_trajectories function is the primary tool for rendering integration results. It can plot multiple trajectories on the same axis and automatically overlay the system’s equilibria as labeled markers.

Basic Usage (3D)

By default, the function creates a 3D scatter/line plot.

import numpy as np
import matplotlib.pyplot as plt
from hidden_attractors.plotting import plot_overlay_trajectories
from hidden_attractors.models import equilibria_nonsmooth, chua_nonsmooth_parameters

# Assuming 'x' is a trajectory array of shape (N, 3)
solutions = [x] 

params = chua_nonsmooth_parameters()
eq = equilibria_nonsmooth(params)

plot_overlay_trajectories(
    solutions=solutions,
    equilibria=eq,
    labels=["Hidden Candidate"],
    view_3d=True,
    alpha=0.8,
    linewidth=0.5
)

plt.show()

2D Projections

Often, a 3D plot is difficult to interpret on a flat screen or paper. You can switch to a 2D projection by setting view_3d=False.

By default, this projects onto the XYXY plane (coordinates 0 and 1). You can change this using the dims argument.

# Project onto the X-Z plane
plot_overlay_trajectories(
    solutions=solutions,
    equilibria=eq,
    view_3d=False,
    dims=(0, 2) # X is index 0, Z is index 2
)

Multiple Trajectories

You can pass a list of multiple trajectories. The function will cycle through a built-in color palette to distinguish them.

# x1 is a self-excited trajectory, x2 is a hidden trajectory
solutions = [x1, x2]
labels = ["Self-Excited", "Hidden"]

plot_overlay_trajectories(solutions, eq, labels)