code: def plot_components(
      m,
      fcst,
      uncertainty=True,
      plot_cap=True,
      weekly_start=0,
      yearly_start=0,
      figsize=None,
  ):
      """Plot the Prophet forecast components.
  
      Will plot whichever are available of: trend, holidays, weekly
      seasonality, yearly seasonality, and additive and multiplicative extra
      regressors.
  
      Parameters
      ----------
      m: Prophet model.
      fcst: pd.DataFrame output of m.predict.
      uncertainty: Optional boolean to plot uncertainty intervals, which will
          only be done if m.uncertainty_samples > 0.
      plot_cap: Optional boolean indicating if the capacity should be shown
          in the figure, if available.
      weekly_start: Optional int specifying the start day of the weekly
          seasonality plot. 0 (default) starts the week on Sunday. 1 shifts
          by 1 day to Monday, and so on.
      yearly_start: Optional int specifying the start day of the yearly
          seasonality plot. 0 (default) starts the year on Jan 1. 1 shifts
          by 1 day to Jan 2, and so on.
      figsize: Optional tuple width, height in inches.
  
      Returns
      -------
      A matplotlib figure.
      """
      # Identify components to be plotted
      components = ["trend"]
      if m.train_holiday_names is not None and "holidays" in fcst:
          components.append("holidays")
      # Plot weekly seasonality, if present
      if "weekly" in m.seasonalities and "weekly" in fcst:
          components.append("weekly")
      # Yearly if present
      if "yearly" in m.seasonalities and "yearly" in fcst:
          components.append("yearly")
      # Other seasonalities
      components.extend(
          [
              name
              for name in sorted(m.seasonalities)
              if name in fcst and name not in ["weekly", "yearly"]
          ]
      )
      regressors = {"additive": False, "multiplicative": False}
      for name, props in m.extra_regressors.items():
          regressors[props["mode"]] = True
      for mode in ["additive", "multiplicative"]:
          if (
              regressors[mode]
              and "extra_regressors_{}".format(mode) in fcst
          ):
              components.append("extra_regressors_{}".format(mode))
      npanel = len(components)
  
      figsize = figsize if figsize else (9, 3 * npanel)
      fig, axes = plt.subplots(
          npanel, 1, facecolor="w", figsize=figsize
      )
  
      if npanel == 1:
          axes = [axes]
  
      multiplicative_axes = []
  
      dt = m.history["ds"].diff()
      min_dt = dt.iloc[dt.values.nonzero()[0]].min()
  
      for ax, plot_name in zip(axes, components):
          if plot_name == "trend":
              plot_forecast_component(
                  m=m,
                  fcst=fcst,
                  name="trend",
                  ax=ax,
                  uncertainty=uncertainty,
                  plot_cap=plot_cap,
              )
          elif plot_name in m.seasonalities:
              if (
                  plot_name == "weekly"
                  or m.seasonalities[plot_name]["period"] == 7
              ) and (min_dt == pd.Timedelta(days=1)):
                  plot_weekly(
                      m=m,
                      name=plot_name,
                      ax=ax,
                      uncertainty=uncertainty,
                      weekly_start=weekly_start,
                  )
              elif (
                  plot_name == "yearly"
                  or m.seasonalities[plot_name]["period"] == 365.25
              ):
                  plot_yearly(
                      m=m,
                      name=plot_name,
                      ax=ax,
                      uncertainty=uncertainty,
                      yearly_start=yearly_start,
                  )
              else:
                  plot_seasonality(
                      m=m,
                      name=plot_name,
                      ax=ax,
                      uncertainty=uncertainty,
                  )
          elif plot_name in [
              "holidays",
              "extra_regressors_additive",
              "extra_regressors_multiplicative",
          ]:
              plot_forecast_component(
                  m=m,
                  fcst=fcst,
                  name=plot_name,
                  ax=ax,
                  uncertainty=uncertainty,
                  plot_cap=False,
              )
          if plot_name in m.component_modes["multiplicative"]:
              multiplicative_axes.append(ax)
  
      fig.tight_layout()
      # Reset multiplicative axes labels after tight_layout adjustment
      for ax in multiplicative_axes:
          ax = set_y_as_percent(ax)
      return fig
  
imports: from __future__ import absolute_import, division, print_function
  import logging
  import numpy
  import pandas
  from prophet.diagnostics import performance_metrics
label_desc: Use image node_id 2 for calling a global function with example usage: plot_components(m, fcst, uncertainty, plot_cap, weekly_start, yearly_start, figsize) and returns: fig