๐ŸŽฏ

XY Plot

Sinks
Run the live example Free ยท no sign-up ยท runs in your browser

The XYPlot block displays the parametric relationship between two real-time scalar signals (x(t)x(t) and y(t)y(t)) in a phase-plane coordinate frame. Unlike time-domain scopes where the horizontal axis represents simulation time, the XYPlot maps the first input directly to the horizontal axis and the second input to the vertical axis. It features an animated fading trail of configurable length, providing immediate visual insight into limit cycles, chaotic attractors, orbital trajectories, state-space portraits, and hysteresis loops.

Mathematical Model

The block samples the continuous or discrete input pair (x(t),y(t))(x(t), y(t)) at each simulation time step tkt_k:

pk=[x(tk)y(tk)]โˆˆR2\mathbf{p}_k = \begin{bmatrix} x(t_k) \\ y(t_k) \end{bmatrix} \in \mathbb{R}^2

The active visual trajectory is maintained in a FIFO sliding queue Tk\mathcal{T}_k of length LL (trailLength):

Tk={piโ€…โ€Š|โ€…โ€Ši=maxโก(0,kโˆ’L+1),โ€ฆ,k}\mathcal{T}_k = \left\{ \mathbf{p}_i \;\middle|\; i = \max(0, k - L + 1), \dots, k \right\}

When L=0L = 0, the queue retains the complete trajectory from simulation start without discarding points.

When autoScale = true, the coordinate viewport bounds expand dynamically to encompass the active trail:

xspan=[minโกpโˆˆTx,โ€…โ€ŠmaxโกpโˆˆTx]yspan=[minโกpโˆˆTy,โ€…โ€ŠmaxโกpโˆˆTy]\begin{aligned} x_{\text{span}} &= \left[ \min_{\mathbf{p} \in \mathcal{T}} x, \; \max_{\mathbf{p} \in \mathcal{T}} x \right] \\ y_{\text{span}} &= \left[ \min_{\mathbf{p} \in \mathcal{T}} y, \; \max_{\mathbf{p} \in \mathcal{T}} y \right] \end{aligned}

When autoScale = false, the viewport is rigidly locked to [xminโก,xmaxโก]ร—[yminโก,ymaxโก][x_{\min}, x_{\max}] \times [y_{\min}, y_{\max}].

Inputs & Outputs

Direction ID Label Type Status
→ In x X number Required
→ In y Y number Required

Parameters

Parameters Label Type Default Description
autoScale Auto Scale Axes boolean true
xMin X Min number -1
xMax X Max number 1
yMin Y Min number -1
yMax Y Max number 1
showGrid Show Grid boolean true
pointColor Point Color string #f97316
trailLength Max Points (0 = keep all) number 0

Usage Examples

Example 1: Van der Pol Nonlinear Oscillator Phase Portrait and Limit Cycle

Visualizing the state-space orbit of a Van der Pol relaxation oscillator xยจโˆ’ฮผ(1โˆ’x2)xห™+x=0\ddot{x} - \mu(1 - x^2)\dot{x} + x = 0. Routing state x(t)x(t) to the XX port and velocity xห™(t)\dot{x}(t) to the YY port with trailLength = 500 and autoScale = true. As simulation time advances, trajectories starting from different initial conditions visibly converge onto the characteristic closed limit cycle.

Example 2: Controller Error vs. Actuator Control Effort Phase Plane

Connecting tracking error e(t)e(t) to the XX input and control effort u(t)u(t) to the YY input with autoScale = true. This visualizes controller gain slope, actuator saturation thresholds, and switching chattering in real time.

Remarks & Best Practices

  • Pure Phase-Plane Formulation: The horizontal axis strictly represents signal x(t)x(t), never simulation time tt. For time-series waveforms, use uPlotDisplay.
  • Sliding-Window Memory Efficiency: Setting a finite trailLength (e.g. 200200 to 10001000 points) ensures bounded memory consumption and fast rendering during long continuous simulation runs.
  • Two Independent Scalar Inputs: Accepts two independent scalar wires on separate XX and YY ports; vector signals should be demuxed before connection.
  • Sink Probe Architecture: Terminal sink block that reads values directly from simulation buffers without creating algebraic loops or altering system dynamics.

Related Components

  • ScatterPlot: Accumulates static point-cloud datasets for statistical correlation analysis.
  • uPlotDisplay: Multi-channel time-series oscilloscope with rolling and expanding windows.
  • NumericDisplay: Real-time LCD digital scalar value readout.
  • StateSpace: Continuous dynamic system often analyzed via phase-plane trajectories.