Skip to content

Orbital Trajectory Plotting

plot_cartesian_trajectory

plot_cartesian_trajectory(trajectories, time_range=None, position_units='km', velocity_units='km/s', backend='matplotlib', show_title=False, show_grid=False, matplotlib_config=None, plotly_config=None, width=None, height=None) -> object

Plot Cartesian orbital elements (position and velocity) vs time.

Creates a 2x3 subplot layout: - Row 1: x, y, z positions - Row 2: vx, vy, vz velocities

Parameters:

Name Type Description Default
trajectories list of dict

List of trajectory groups, each with: - trajectory: OrbitTrajectory or numpy array [N×6] or [N×7] - times (np.ndarray, optional): Time array if trajectory is numpy array without time column - color (str, optional): Line/marker color - marker (str, optional): Marker style - label (str, optional): Legend label

required
time_range tuple

(start_epoch, end_epoch) to filter data

None
position_units str

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

'km'
velocity_units str

'm/s' or 'km/s'. Default: 'km/s'

'km/s'
backend str

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

'matplotlib'
show_title bool

Whether to display plot title. Default: False

False
show_grid bool

Whether to display grid lines. Default: False

False
matplotlib_config dict

Matplotlib-specific configuration: - legend_subplot (tuple): (row, col) of subplot for legend. Default: (0, 0) - legend_loc (str): Legend location. Default: 'best' Options: 'best', 'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center' - dark_mode (bool): Apply dark mode styling. Default: False - ylabel_pad (float): Padding for y-axis labels. Default: 10 - figsize (tuple): Figure size (width, height). Default: (15, 10)

None
plotly_config dict

Plotly-specific configuration (reserved for future use)

None
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 + 2*bh.orbital_period(oe[0]), 60.0)

# Plot Cartesian elements with legend in upper right of Z position subplot
fig = bh.plot_cartesian_trajectory(
    [{"trajectory": traj, "label": "LEO Orbit"}],
    position_units='km',
    velocity_units='km/s',
    backend='matplotlib',
    matplotlib_config={'legend_subplot': (0, 2), 'legend_loc': 'upper right'}
)

plot_keplerian_trajectory

plot_keplerian_trajectory(trajectories, time_range=None, angle_units='deg', sma_units='km', normalize_angles=False, backend='matplotlib', show_title=False, show_grid=False, matplotlib_config=None, plotly_config=None, width=None, height=None) -> object

Plot Keplerian orbital elements vs time.

Creates a 2x3 subplot layout: - Row 1: a (semi-major axis), e (eccentricity), i (inclination) - Row 2: Ω (RAAN), ω (argument of periapsis), M (mean anomaly)

Parameters:

Name Type Description Default
trajectories list of dict

List of trajectory groups, each with: - trajectory: OrbitTrajectory or numpy array [N×6] or [N×7] as [a, e, i, Ω, ω, M] - times (np.ndarray, optional): Time array if trajectory is numpy array without time column - color (str, optional): Line/marker color - marker (str, optional): Marker style - label (str, optional): Legend label

required
time_range tuple

(start_epoch, end_epoch) to filter data

None
angle_units str

'rad' or 'deg'. Default: 'deg'

'deg'
sma_units str

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

'km'
normalize_angles bool

If True, wrap angles to [0, 2π) or [0, 360°). Default: False

False
backend str

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

'matplotlib'
show_title bool

Whether to display plot title. Default: False

False
show_grid bool

Whether to display grid lines. Default: False

False
matplotlib_config dict

Matplotlib-specific configuration: - legend_subplot (tuple): (row, col) of subplot for legend. Default: (0, 0) - legend_loc (str): Legend location. Default: 'best' Options: 'best', 'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center' - dark_mode (bool): Apply dark mode styling. Default: False - ylabel_pad (float): Padding for y-axis labels. Default: 10 - figsize (tuple): Figure size (width, height). Default: (15, 10) - set_angle_ylim (bool): Set y-axis limits to [0, 360°] or [0, 2π]. Default: False - set_eccentricity_ylim (bool): Set y-axis limits to [0, 1]. Default: False

None
plotly_config dict

Plotly-specific configuration: - set_angle_ylim (bool): Set y-axis limits to [0, 360°] or [0, 2π]. Default: False - set_eccentricity_ylim (bool): Set y-axis limits to [0, 1]. Default: False

None
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, 97.8, 0.0, 0.0, 0.0])

prop = bh.KeplerianPropagator.from_eci(epoch, oe, bh.AngleFormat.DEGREES, 60.0)
traj = prop.propagate(epoch, epoch + 2*bh.orbital_period(oe[0]), 60.0)

# Plot Keplerian elements
fig = bh.plot_keplerian_trajectory(
    [{"trajectory": traj, "label": "LEO Orbit"}],
    angle_units='deg',
    sma_units='km',
    backend='matplotlib'
)