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_system_3d(sim, time=200 * orb.seconds_per_day, trails=True)plot_system_3d
plot_system_3d(sim_data, time=None, trails=False)Plot where every body is at a single time in interactive 3D.
The 3D counterpart to plot_system. Draws one marker per body at its position at the chosen time in a plotly 3D scene, optionally with the full trajectories drawn faintly behind. Drag to rotate, scroll to zoom, and hover over a marker to see the body name, the time in days and the coordinates in meters.
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 |
Returns
| Name | Type | Description |
|---|---|---|
| plotly.graph_objects.Figure | A figure with one Scatter3d marker per body, axes labelled in meters and a title giving the time shown, in seconds. 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. | |
| ValueError | If sim_data has no time column. |
See Also
plot_system: Picks 2D or 3D from the data.plot_orbits_3d: Whole trajectories in 3D.animate_system_3d: The same scene with a play button and time slider.
Notes
The three axes share one scale and are fitted to what is drawn. Without trails that is only the markers, so the view is tight around the bodies. With trails=True it covers the whole trajectories.
Examples
Mars on an orbit tilted 25 degrees, 200 days into the simulation.