Legs¶
A carrier-wide average can hide a lot of variation between flights. Here we can look at individual legs—a single flight from one airport to another—and see which ones are full, which carry connecting passengers, and how their results change between runs.
You can read about the underlying data and how to collect it in Legs.
Load Factor Distribution¶
This histogram groups legs by load factor—the percentage of seats sold. It helps you see whether most legs have similar loads or whether the network has a mixture of full and lightly loaded flights.
For one run, call
fig_leg_load_factor_distribution
on a single SimulationTables object:
summary.fig_leg_load_factor_distribution()
To focus on one carrier, pass its name to
fig_leg_load_factor_distribution
on the same SimulationTables object:
summary.fig_leg_load_factor_distribution(by_carrier="Tapas")
normalize=True shows the fraction of legs in each range instead of their count, which helps when
carriers have different numbers of flights.
Call
fig_leg_load_factor_distribution
on a single SimulationTables object with that option:
summary.fig_leg_load_factor_distribution(normalize=True)
To choose your own range boundaries, pass breakpoints to
fig_leg_load_factor_distribution
on the same SimulationTables object:
summary.fig_leg_load_factor_distribution(breakpoints=[70,80,90])
To compare scenarios, make this chart once for each result. There isn’t a combined comparison method for this figure.
Local Share Distribution¶
This histogram groups legs by their share of local passengers. Legs with a low local share mainly carry connecting traffic; those with a high local share mainly serve passengers traveling directly between their endpoints.
Use by_carrier, breakpoints, and normalize as in the load-factor distribution.
For one run, call
fig_leg_local_share_distribution
on a single SimulationTables object:
summary.fig_leg_local_share_distribution(normalize=True)
To focus on one carrier, call
fig_leg_local_share_distribution
on the same SimulationTables object with by_carrier:
summary.fig_leg_local_share_distribution(by_carrier="Tapas", normalize=True)
To compare scenarios, make this chart once for each result. There isn’t a combined comparison method for this figure.
Load Factor v Local Flow¶
This scatter plot shows the relationship between load factor and local share across legs. Each point represents a leg. By plotting load factor against the share of local passengers, we can look for patterns—for example, whether legs carrying more connecting passengers also tend to be fuller.
For one run, call
fig_leg_load_v_local on a single
SimulationTables object:
summary.fig_leg_load_v_local()
Filter with orig, dest, place (either endpoint), or carrier. For example, call
fig_leg_load_v_local on the same
SimulationTables object to select one carrier:
summary.fig_leg_load_v_local(carrier="Tapas")
Calling this function with select_leg=True returns an interactive notebook widget for select-leg
analysis, rather than an ordinary standalone chart. For any leg you click on in the scatterplot, the
widget shows the origins, destinations, and booking classes of passengers using that leg.
To compare scenarios, make this chart once for each result. There isn’t a combined comparison method for this figure.
Load Factor v Distance¶
Are longer flights fuller than shorter ones? This scatter plot puts each leg’s load factor alongside
its distance so you can explore that question. For one run, call
fig_leg_load_v_distance on a
single SimulationTables object:
summary.fig_leg_load_v_distance()
Filter with orig, dest, place, or carrier, the same as for
fig_leg_load_v_local. For example,
call fig_leg_load_v_distance on
the same SimulationTables object to select an airport:
summary.fig_leg_load_v_distance(place="MAD")
This figure is particularly prone to having many overlapping points. The beeswarm argument can
separate points that overlap, by moving points slightly so they don’t overlap as much.
Pass beeswarm to
fig_leg_load_v_distance on the
same SimulationTables object:
summary.fig_leg_load_v_distance(beeswarm=1000)
To compare scenarios, make this chart once for each result. There isn’t a combined comparison method for this figure.
Select Leg Analysis¶
A passenger on a leg may have started somewhere else or may be connecting onward. These panels show the origins, destinations, and booking classes of passengers using the leg or legs you select.
Generating this figure requires that both path_legs and pathclasses tables are available for the
select-leg analysis.
For one run, call
fig_select_leg_analysis on a
single SimulationTables object:
summary.fig_select_leg_analysis(leg_id=111)
The breakdown of leg customers can be one of two metrics: either bookings (the default) or
revenue.
To show revenue, call
fig_select_leg_analysis on the
same SimulationTables object with metric="revenue":
summary.fig_select_leg_analysis(leg_id=111, metric="revenue")
To compare scenarios, make this chart once for each result. There isn’t a combined comparison method for this figure.
Duo Comparison: Leg Shifts¶
This figure will compare load factor and local share for the same legs in two runs. Lines connect baseline to treatment and points mark treatment outcomes, with marker size representing leg capacity. Use this tool for matched networks (i.e. before and after treatments).
To compare two runs, call fig_leg_shifts with two
SimulationTables objects: the baseline first, followed
by the treatment. This is a standalone function, so import it before calling it:
from passengersim.contrast.duo import fig_leg_shifts
fig_leg_shifts(baseline, alternative, coloring="change_revenue_pct")
This function compares exactly two results. It is not a method on a
Contrast object and has no single-run equivalent.
Callback Analysis: Leg Booking Detail¶
If you want to see how bookings grow over the booking horizon, and how that growth varies from sample to sample, this chart is useful. It shows the median and selected percentiles for one leg. For example, the 10th and 90th percentiles help you see the range containing most observations. You’ll need to to set up a callback to collect daily booking detail on the legs of interest before running the simulation, as the average totals alone don’t contain that information.
The standard demo archive has no daily booking callbacks. This code replays europa/upe with the
same simulation settings and an extra collector for Tapas flight 111 (KEF–MAD). It caches the
recorded result separately so you only need to collect it once.
from pathlib import Path
import tempfile
from passengersim.contrast import Contrast
from passengersim.callbacks.booking_detail import collect_leg_booking_detail
def collect_demo(name: str) -> pax.SimulationTables:
"""Replay a demo with the recording needed by this page."""
cfg = pax.Config.from_yaml(pax.demo_network(name))
cfg.outputs._write_no_files()
cfg.outputs.reports = set()
cfg.simulation_controls.show_progress_bar = False
cfg.db = None
cache_dir = Path(tempfile.gettempdir()) / "passengersim-viz-guide" / "booking-detail" / name
simulation_class = pax.MultiSimulation if cfg.simulation_controls.num_trials > 1 else pax.Simulation
with simulation_class(cfg) as sim:
sim.daily_callback(collect_leg_booking_detail({111, 201}))
return sim.run(cache_dir=cache_dir)
recorded_summary = collect_demo("europa/upe")
Cache miss for config with hash af3654135d9e8cb7c4a32481a6281bff098368dfd9b30567da2470f9b66f6c80. Running simulation and saving summary to cache.
╭─────────────────── Summary revenue statistics · Europa ───────────────────╮ │ Brat Stroop Tapas │ │ Run Samples Mean ~95% CI Mean ~95% CI Mean ~95% CI │ │ Europa 900 968.6K ±8,193 935.5K ±8,308 291.7K ±2,130 │ │ Post-burn-in only · Approx. 95% CI for mean │ ╰───────────────────────────────────────────────────────────────────────────╯
For one run, call
fig_leg_booking_detail_rake
on a single SimulationTables object:
recorded_summary.fig_leg_booking_detail_rake(leg_id=111)
To inspect another leg, call
fig_leg_booking_detail_rake
on the same SimulationTables object with a different
leg_id:
recorded_summary.fig_leg_booking_detail_rake(leg_id=201)
The collector can also be enabled in a configuration instead of attached in Python, using
callbacks: {leg_booking_detail: {parameters: {leg_ids: [111, 201]}}}; the summary methods are the
same either way.
There is no dedicated comparison method; collect and plot the same leg in each run separately.