fig_displacement_history

passengersim.contrast.fig_displacement_history(summaries: dict[str, SimulationTables], *, by_carrier: bool | str = True, show_stdev: float | bool | None = None, raw_df: bool = False, title: str | None = 'Displacement Cost History', also_df: bool = False, width: int = 225, height: int = 125) Chart | DataFrame | tuple[Chart, DataFrame][source]

Generate a figure contrasting displacement cost history for one or more runs.

Plots average displacement costs vs. days prior to departure, with one line per source. When multiple carriers are present and by_carrier is not a string, the chart is faceted by carrier.

Parameters:
summaries : dict[str, SimulationTables]

One or more SimulationTables to compare.

by_carrier : bool or str, default True

If True, facet the chart by carrier. If a string, filter to only that carrier and return a single unfaceted chart.

show_stdev : float or bool, optional

If truthy, overlay a shaded band and dashed boundary lines showing the displacement cost distribution width. Requires by_carrier to be a specific carrier string.

raw_df : bool, default False

If True, return the raw DataFrame instead of the chart.

title : str, optional

Chart title. Defaults to "Displacement Cost History". Pass None for no title.

also_df : bool, default False

If True, return a tuple of (figure, dataframe) instead of just the figure.

width : int, default 225

Width of each facet panel in pixels.

height : int, default 125

Height of each facet panel in pixels.

Returns:

alt.Chart or pd.DataFrame or tuple[alt.Chart, pd.DataFrame] – The Altair chart, or the raw DataFrame if raw_df is True, or a (chart, dataframe) tuple if also_df is True.

Raises:

NotImplementedError – If show_stdev is truthy and by_carrier is not a specific carrier string.