Plotting

Plotting functions. Each returns the matplotlib Axes it drew on.

omnicast.plot_metric_by_horizon(metrics_df, metric_col, title='Metric by Forecast Horizon', ylabel=None, colors=None, horizons=None, target_val=None, is_percentage=False, figsize=(10, 5), ax=None, save_path=None)[source]

Plot a metric across forecast horizons, one line per model.

Parameters:
  • metrics_df (DataFrame) – Long-format table with columns model, horizon, and metric_col.

  • metric_col (str) – Metric column to plot on the y-axis.

  • title (str) – Title and y-axis label (ylabel defaults to metric_col).

  • ylabel (str | None) – Title and y-axis label (ylabel defaults to metric_col).

  • colors (dict[str, str] | None) – Mapping of model name to line colour.

  • horizons (list[int] | None) – x-axis ticks. Defaults to the sorted unique horizons in the data.

  • target_val (float | None) – Reference value drawn as a horizontal dashed line.

  • is_percentage (bool) – Multiply values and target_val by 100 before plotting.

  • figsize (tuple[float, float]) – Figure size when a new figure is created.

  • ax (Axes | None) – Axes to draw on. A new figure is created when omitted.

  • save_path (str | None) – If given, save the figure here at 300 dpi.

Return type:

Axes

omnicast.plot_backtest(result, observed=None, title='Backtest Out-of-Sample Predictions', show_intervals=True, figsize=(10, 5), ax=None, save_path=None)[source]

Plot rolling-origin backtest predictions against observations.

Parameters:
  • result (BacktestResult | DataFrame) – A BacktestResult (its .predictions are used) or the predictions table directly: columns cutoff, target_date, predicted, and optional lower_* / upper_*.

  • observed (Series | None) – History to draw the predictions against. Defaults to result.observed (a BacktestResult always carries it), then to the actual column of the predictions.

  • title (str)

  • show_intervals (bool) – Draw the per-fold interval band when interval columns are present.

  • figsize (tuple[float, float])

  • ax (Axes | None)

  • save_path (str | None)

Return type:

Axes