Draws one marker per body at its position at the chosen time, optionally with the full trajectories drawn faintly behind. This is the snapshot counterpart to plot_orbits, which draws the whole trajectories.
If every z value in sim_data is zero, a 2D matplotlib plot is drawn. If any z value is non-zero, the work is handed to plot_system_3d, which returns an interactive plotly figure. Use three_d to force one or the other.
Parameters
Name
Type
Description
Default
sim_data
DataFrame
The output of simulate_system (pandas or polars). It must have the columns id, x, y, z (meters) and time (seconds).
required
time
float
The time to show, in seconds from the start of the simulation. The closest recorded time step is used. The default, None, shows the last time step.
None
trails
bool
If True, the full trajectory of each body is drawn faintly behind its marker. The default, False, shows only the markers.
False
three_d
bool
None (the default) picks 3D only when there is motion in z. True forces a 3D plotly figure even for planar data. False forces a 2D plot, which shows the projection onto the x-y plane.
None
ax
matplotlib.axes.Axes
Axes to draw the 2D plot on. By default a new 7 by 7 inch figure is created. Ignored when the plot is 3D.
None
Returns
Name
Type
Description
matplotlib.axes.Axes or plotly.graph_objects.Figure
The matplotlib Axes for a 2D plot, with an equal aspect ratio, axes labelled in meters and a legend of body names. A plotly Figure for a 3D plot. Either way the title gives the time shown, in seconds.
The 2D axis limits always cover the whole trajectories, whether or not trails is set. Snapshots of the same simulation at different times therefore share one frame and can be compared directly.
plotly is an optional dependency. If a 3D plot is called for and plotly is not installed, a warning is issued and the 2D plot is drawn instead.
Examples
The final state of a one-year simulation, with the orbits drawn behind.