Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


ax_streamline (Fx, Fy, xvar, xlo, xhi, yvar, ylo, yhi) — Function

Streamline / phase portrait curves for a 2D ODE system dx/dt = Fx(x,y), dy/dt = Fy(x,y). Use inside ax_draw2d. Integrates trajectories from initial points using RK4.

Combine with ax_vector_field for a full phase portrait:

ax_draw2d(
  color="#cccccc", ax_vector_field(-y, x, x, -3, 3, y, -3, 3),
  color="red", ax_streamline(-y, x, x, -3, 3, y, -3, 3),
  aspect_ratio=true, title="Phase Portrait"
)$

Examples

/* Auto initial points */
ax_draw2d(ax_streamline(-y, x, x, -3, 3, y, -3, 3))$

/* Custom initial points and time range */
ax_draw2d(
  initial_points=[[0.5,0.5],[2,2],[3,1]],
  t_range=[0,20], dt=0.01,
  ax_streamline(x*(1-y), y*(x-1), x, 0, 4, y, 0, 4),
  title="Lotka-Volterra"
)$

Relevant Options

OptionDefaultDescription
initial_pointsautoList of [x0,y0] starting points
t_range[0, 10]Integration time span [t0, tf]
dt0.05RK4 step size
colorautoCurve color
line_width1.5Curve thickness
nameautoLegend entry
opacity1.0Trace opacity

See also: ax_draw2d, ax_vector_field