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)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
plot_orbits: Picks 2D or 3D from the data.plot_system_3d: Positions at a single time in 3D.animate_system_3d: The same scene with a play button and time slider.
Examples
Mars on an orbit tilted 25 degrees out of Earth’s orbital plane.