code: def decomp_plot(
      df,
      time,
      signal,
      estimator,
      residue,
      name=None,
      format="png",
      max_length=1000,
  ):
      assert df.shape[0] > 0
      assert df.shape[1] > 0
      assert time in df.columns
      assert signal in df.columns
      assert estimator in df.columns
      assert residue in df.columns
  
      import matplotlib
  
      # print("MATPLOTLIB_BACKEND",  matplotlib.get_backend())
      # matplotlib.use('Agg')
      import matplotlib.pyplot as plt
  
      df1 = df.tail(max_length)
      if name is not None:
          plt.switch_backend("Agg")
      fig, axs = plt.subplots(ncols=2, figsize=(32, 16))
      lColor = COMPONENT_COLOR
      if name is not None and name.endswith("Forecast"):
          lColor = FORECAST_COLOR
      df1.plot.line(
          time,
          [signal, estimator, residue],
          color=[SIGNAL_COLOR, lColor, RESIDUE_COLOR],
          ax=axs[0],
          grid=True,
          legend=False,
      )
      add_patched_legend(axs[0], [signal, estimator, residue])
      residues = df1[residue].values
  
      import scipy.stats as scistats
  
      resid = residues[~np.isnan(residues)]
      scistats.probplot(resid, dist="norm", plot=axs[1])
  
      if name is not None:
          plt.switch_backend("Agg")
          fig.savefig(name + "_decomp_output." + format)
          plt.close(fig)
  
file_path: atspy/atspy/TS/Plots.py
imports: import pandas
  import numpy
  from io import BytesIO
  import base64
label_desc: Use image node_id 2 for calling a global function with example usage: decomp_plot(df, time, signal, estimator, residue, name, format, max_length) without return types