module utilsforecast.plotting

Time series visualizations

Global Variables

  • TYPE_CHECKING

function plot_series

plot_series(
    df: Optional[~DFType] = None,
    forecasts_df: Optional[~DFType] = None,
    ids: Optional[List[str]] = None,
    plot_random: bool = True,
    max_ids: int = 8,
    models: Optional[List[str]] = None,
    level: Optional[List[float]] = None,
    max_insample_length: Optional[int] = None,
    plot_anomalies: bool = False,
    engine: str = 'matplotlib',
    palette: Optional[str] = None,
    id_col: str = 'unique_id',
    time_col: str = 'ds',
    target_col: str = 'y',
    seed: int = 0,
    resampler_kwargs: Optional[Dict] = None,
    ax: Optional[Axes, ndarray, ForwardRef('Figure')] = None
)
Plot forecasts and insample values. Args:
  • df (pandas or polars DataFrame, optional): DataFrame with columns [id_col, time_col, target_col]. Defaults to None.
  • forecasts_df (pandas or polars DataFrame, optional): DataFrame with columns [id_col, time_col] and models. Defaults to None.
  • ids (list of str, optional): Time Series to plot. If None, time series are selected randomly. Defaults to None.
  • plot_random (bool, optional): Select time series to plot randomly. Defaults to True.
  • max_ids (int, optional): Maximum number of ids to plot. Defaults to 8.
  • models (list of str, optional): Models to plot. Defaults to None.
  • level (list of float, optional): Prediction intervals to plot. Defaults to None.
  • max_insample_length (int, optional): Maximum number of train/insample observations to be plotted. Defaults to None.
  • plot_anomalies (bool, optional): Plot anomalies for each prediction interval. Defaults to False.
  • engine (str, optional): Library used to plot. ‘plotly’, ‘plotly-resampler’ or ‘matplotlib’. Defaults to ‘matplotlib’.
  • palette (str, optional): Name of the matplotlib colormap to use for the plots. If None, uses the current style. Defaults to None.
  • id_col (str, optional): Column that identifies each serie. Defaults to ‘unique_id’.
  • time_col (str, optional): Column that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.
  • target_col (str, optional): Column that contains the target. Defaults to ‘y’.
  • seed (int, optional): Seed used for the random number generator. Only used if plot_random is True. Defaults to 0.
  • resampler_kwargs (dict, optional): Keyword arguments to be passed to plotly-resampler constructor. For further custumization (“show_dash”) call the method, store the plotting object and add the extra arguments to its show_dash method. Defaults to None. ax (matplotlib axes, array of matplotlib axes or plotly Figure, optional): Object where plots will be added. Defaults to None.
Returns:
  • matplotlib or plotly figure: Plot’s figure