class_docstr: Abstract class representing predictions.
class_docstr_tok: ["Abstract","class","representing","predictions","."]
docstr: Plot median forecast and prediction intervals using ``matplotlib``.
  
  By default the `0.5` and `0.9` prediction intervals are plotted. Other
  intervals can be choosen by setting `intervals`.
  
  This plots to the current axes object (via ``plt.gca()``), or to ``ax``
  if provided. Similarly, the color is using matplotlibs internal color
  cycle, if no explicit ``color`` is set.
  
  One can set ``name`` to use it as the ``label`` for the median
  forecast. Intervals are not labeled, unless ``show_label`` is set to
  ``True``.
code: def plot(
      self,
      *,
      intervals=(0.5, 0.9),
      ax=None,
      color=None,
      name=None,
      show_label=False,
  ):
      """
      Plot median forecast and prediction intervals using ``matplotlib``.
  
      By default the `0.5` and `0.9` prediction intervals are plotted. Other
      intervals can be choosen by setting `intervals`.
  
      This plots to the current axes object (via ``plt.gca()``), or to ``ax``
      if provided. Similarly, the color is using matplotlibs internal color
      cycle, if no explicit ``color`` is set.
  
      One can set ``name`` to use it as the ``label`` for the median
      forecast. Intervals are not labeled, unless ``show_label`` is set to
      ``True``.
      """
      import matplotlib.pyplot as plt
  
      # Get current axes (gca), if not provided explicitly.
      ax = maybe.unwrap_or_else(ax, plt.gca)
  
      # If no color is provided, we use matplotlib's internal color cycle.
      # Note: This is an internal API and might change in the future.
      color = maybe.unwrap_or_else(
          color, lambda: ax._get_lines.get_next_color()
      )
  
      # Plot median forecast
      ax.plot(
          self.index.to_timestamp(),
          self.quantile(0.5),
          color=color,
          label=name,
      )
  
      # Plot prediction intervals
      for interval in intervals:
          if show_label:
              if name is not None:
                  label = f"{name}: {interval}"
              else:
                  label = interval
          else:
              label = None
  
          # Translate interval to low and high values. E.g for `0.9` we get
          # `low = 0.05` and `high = 0.95`. (`interval + low + high == 1.0`)
          # Also, higher interval values mean lower confidence, and thus we
          # we use lower alpha values for them.
          low = (1 - interval) / 2
          ax.fill_between(
              # TODO: `index` currently uses `pandas.Period`, but we need
              # to pass a timestamp value to matplotlib. In the future this
              # will use ``zebras.Periods`` and thus needs to be adapted.
              self.index.to_timestamp(),
              self.quantile(low),
              self.quantile(1 - low),
              # Clamp alpha betwen ~16% and 50%.
              alpha=0.5 - interval / 3,
              facecolor=color,
              label=label,
          )
  
imports: import re
  import logging
  from dataclasses import field
  from typing import Callable, Dict, List, Optional, Union, Tuple
  import numpy
  import pandas
  from gluonts.core.component import validated
  from gluonts.pydantic import dataclass
  from gluonts import maybe
label_desc: Use image node_id 7 for calling the Forecast obj's underlying member method code with example usage: obj.plot() without return types