Skip to content

3D Trajectory Visualization

plot_trajectory_3d

plot_trajectory_3d(trajectories, time_range=None, units='km', normalize=False, view_azimuth=45.0, view_elevation=30.0, view_distance=None, show_earth=True, earth_texture=None, sphere_resolution_lon=1080, sphere_resolution_lat=540, backend='matplotlib', width=None, height=None) -> object

Plot 3D trajectory in ECI frame.

Parameters:

Name Type Description Default
trajectories list of dict

List of trajectory groups, each with: - trajectory: OrbitTrajectory or numpy array [N×3] or [N×6] (positions in ECI) - color (str, optional): Line color - line_width (float, optional): Line width - label (str, optional): Legend label

required
time_range tuple

(start_epoch, end_epoch) to filter data

None
units str

'm' or 'km'. Default: 'km'

'km'
normalize bool

Normalize to Earth radii. Default: False

False
view_azimuth float

Camera azimuth angle (degrees). Default: 45.0

45.0
view_elevation float

Camera elevation angle (degrees). Default: 30.0

30.0
view_distance float

Camera distance multiplier. Default: 2.5 (larger = further out)

None
show_earth bool

Show Earth sphere at origin. Default: True

True
earth_texture str

Texture to use for Earth sphere (plotly only). Options: - 'simple': Solid lightblue sphere (fast rendering) - 'blue_marble': NASA Blue Marble texture (packaged with brahe, default for plotly) - 'natural_earth_50m': Natural Earth 50m shaded relief (auto-downloads ~20MB) - 'natural_earth_10m': Natural Earth 10m shaded relief (auto-downloads ~180MB) Note: matplotlib always uses a simple solid sphere regardless of this setting. Default: 'blue_marble' for plotly

None
sphere_resolution_lon int

Longitude resolution for textured sphere (plotly only). Higher values = better quality but slower rendering. Default: 1080

1080
sphere_resolution_lat int

Latitude resolution for textured sphere (plotly only). Higher values = better quality but slower rendering. Default: 540

540
backend str

'matplotlib' or 'plotly'. Default: 'matplotlib'

'matplotlib'
width int

Figure width in pixels (plotly only). Default: None (responsive)

None
height int

Figure height in pixels (plotly only). Default: None (responsive)

None

Returns:

Type Description
object

Generated figure object

Example
import brahe as bh
import numpy as np

# Create trajectory
eop = bh.FileEOPProvider.from_default_standard(bh.EarthOrientationFileType.STANDARD, True)
bh.set_global_eop_provider(eop)

epoch = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
oe = np.array([bh.R_EARTH + 500e3, 0.01, np.radians(97.8), 0.0, 0.0, 0.0])
state = bh.state_koe_to_eci(oe, bh.AngleFormat.RADIANS)

prop = bh.KeplerianPropagator.from_eci(epoch, state, 60.0)
traj = prop.propagate(epoch, epoch + bh.orbital_period(oe[0]), 60.0)

# Plot 3D trajectory with matplotlib (simple sphere)
fig = bh.plot_trajectory_3d(
    [{"trajectory": traj, "color": "red", "label": "LEO Orbit"}],
    units='km',
    show_earth=True,
    backend='matplotlib'
)

# Plot 3D trajectory with plotly (blue marble texture by default)
fig = bh.plot_trajectory_3d(
    [{"trajectory": traj, "color": "red", "label": "LEO Orbit"}],
    units='km',
    show_earth=True,
    backend='plotly'
)

# Plot with explicit texture choice
fig = bh.plot_trajectory_3d(
    [{"trajectory": traj, "color": "red", "label": "LEO Orbit"}],
    units='km',
    show_earth=True,
    earth_texture='natural_earth_50m',
    backend='matplotlib'
)