code: def tsdisplay(
      y,
      lag_max=50,
      figsize=(8, 6),
      title=None,
      bins=25,
      series_kwargs=None,
      acf_kwargs=None,
      hist_kwargs=None,
      show=True,
  ):
      """Display the time series and some of its key statistics
  
      The equivalent of R's ``forecast::tsdisplay``, showing the series, the
      histogram and the ACF plot.
  
      Parameters
      ----------
      y : array-like, shape=(n_samples,)
          The series or numpy array for which to plot an auto-correlation.
  
      lag_max : int, optional (default=50)
          The number of lags for the ACF plot
  
      figsize : tuple, optional (default=(8, 6))
          The size of the figure
  
      title : str, optional (default=None)
          A title for the series, if any.
  
      bins : int, optional (default=25)
          The number of bins for the histogram
  
      series_kwargs : dict or None, optional (default=None)
          Keyword arguments to pass when plotting the series
  
      acf_kwargs : dict or None, optional (default=None)
          Keyword arguments to pass when plotting the ACF
  
      hist_kwargs : dict or None, optional (default=None)
          Keyword arguments to pass when plotting the histogram
  
      show : bool, optional (default=True)
          Whether to show the plot after it's been created. If not, will return
          the plot as a Figure object instead.
  
      Examples
      --------
      >>> import pmdarima as pm
      >>> tsdisplay(pm.datasets.load_sunspots(), show=False)
      <Figure size 800x600 with 3 Axes>
  
      Returns
      -------
      plt : Figure or None
          If ``show`` is True, does not return anything. If False, returns
          the Figure object.
      """
  
      _err_for_no_mpl()
      from matplotlib import gridspec
  
      fig = mpl.figure(figsize=figsize)
      gs = gridspec.GridSpec(4, 2)
      ax0 = fig.add_subplot(gs[0:2, 0:])
      ax1 = fig.add_subplot(gs[2:, 0])
      ax2 = fig.add_subplot(gs[2:, 1])
  
      # make sure y is a np array
      y = check_endog(y, copy=False, preserve_series=True)
  
      if lag_max >= y.shape[0]:
          raise ValueError(
              f"lag_max ({lag_max}) must be < length of the "
              f"series ({y.shape[0]})"
          )
  
      # ax0 is simply the series itself
      x0 = np.arange(y.shape[0])
      xlabs = None
      if hasattr(y, "index"):
          xlabs = y.index.tolist()
          y = y.values
      series_kwargs = {} if not series_kwargs else series_kwargs
      ax0.plot(x0, y, **series_kwargs)
      if title:
          ax0.set_title(title)
  
      if xlabs is not None:
          # TODO: eventually would be nice to do some well spaced xticks
          pass
  
      # ax1 is the ACF, so we can just use our ACF plotting func
      acf_kwargs = {} if not acf_kwargs else acf_kwargs
      plot_acf(
          y, ax=ax1, show=False, title="ACF", lags=lag_max, **acf_kwargs
      )
  
      # ax2 is simply the histogram
      hist_kwargs = {} if not hist_kwargs else hist_kwargs
      _ = ax2.hist(y, bins=bins, **hist_kwargs)  # noqa
      ax2.set_title("Frequency")
  
      fig.tight_layout()
      return _show_or_return(fig, show)
  
file_path: pmdarima/pmdarima/utils/visualization.py
imports: from .array import check_endog
  from ..compat.pandas import plotting
  from ..compat.matplotlib import get_compatible_pyplot
  from statsmodels.graphics import tsaplots
  import numpy
  import os
label_desc: Use image node_id 8 for calling a global function with example usage: tsdisplay(y, lag_max, figsize, title, bins, series_kwargs, acf_kwargs, hist_kwargs, show) and returns: _show_or_return