Skip to main content

plot_orbits_3d

plot_orbits_3d(sim_data)

Plot the full trajectory of every body in interactive 3D.

Draws one line per body in a plotly 3D scene. Drag to rotate, scroll to zoom, and hover over a line to see the body name and the time in days. The three axes share one scale, so a circular orbit looks circular from any angle.

plot_orbits calls this function for you when the data has motion in z. Call it directly when you always want the 3D figure.

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

Returns

Name Type Description
plotly.graph_objects.Figure A figure with one Scatter3d line per body and axes labelled in meters. It displays itself in a notebook. Use fig.show() in a script or fig.write_html(path) to save it.

Raises

Name Type Description
ImportError If plotly is not installed.

See Also

Examples

Mars on an orbit tilted 25 degrees out of Earth’s orbital plane.

import pyorbiter as orb

sim = (
    orb.create_system()
    .add_sun()
    .add_planet("Earth", parent="Sun")
    .add_planet("Mars", parent="Sun", i=25)
    .simulate(time_step=orb.seconds_per_day, duration=2 * orb.seconds_per_year)
)
orb.plot_orbits_3d(sim)