Visualizers#
Reusable customizable plots and animations, independent of numerical solvers.
- engineeringkit.visualizers.animate_displacement(t, displacement, *, interval=30)[source]#
Animate a mass moving along a line.
- Parameters:
t (array_like) – Sample times [s], one-dimensional.
displacement (array_like) – Displacement at each time [m], same shape as
t.interval (float, optional) – Delay between frames [ms], positive. Samples play at this rate, independently of physical time.
- Returns:
(fig, animation), the animation amatplotlib.animation.FuncAnimation. Keep a reference to it until it is shown or saved.- Return type:
tuple
Notes
Inputs are raw SI numbers with no dimensional metadata; see Numerical methods and inspectable histories.
- engineeringkit.visualizers.plot_history(t, history, labels=None, ax=None)[source]#
Plot scalar or vector state histories against time.
- Parameters:
t (array_like) – Sample times [s], one-dimensional.
history (array_like) – States, shape
(len(t),)or(len(t), states).labels (sequence of str, optional) – One label per state, including its unit (e.g.
"x [m]").ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.
- Returns:
(fig, ax).- Return type:
tuple
Notes
Inputs are raw SI numbers with no dimensional metadata; see Numerical methods and inspectable histories.