code: def plot_design_matrix(
      design_matrix, rescale=True, ax=None, output_file=None
  ):
      """Plot a design matrix provided as a :class:`pandas.DataFrame`.
  
      Parameters
      ----------
      design matrix : :class:`pandas.DataFrame`
          Describes a design matrix.
  
      rescale : :obj:`bool`, default=True
          Rescale columns magnitude for visualization or not.
  
      ax : :class:`matplotlib.axes.Axes`, optional
          Handle to axes onto which we will draw the design matrix.
      %(output_file)s
  
      Returns
      -------
      ax : :class:`matplotlib.axes.Axes`
          The axes used for plotting.
  
      """
      # normalize the values per column for better visualization
      _, X, names = check_design_matrix(design_matrix)
      if rescale:
          X = X / np.maximum(
              1.0e-12, np.sqrt(np.sum(X**2, 0))
          )  # pylint: disable=no-member
      if ax is None:
          max_len = np.max([len(str(name)) for name in names])
          fig_height = 1 + 0.1 * X.shape[0] + 0.04 * max_len
          if fig_height < 3:
              fig_height = 3
          elif fig_height > 10:
              fig_height = 10
          plt.figure(figsize=(1 + 0.23 * len(names), fig_height))
          ax = plt.subplot(1, 1, 1)
  
      ax.imshow(X, interpolation="nearest", aspect="auto")
      ax.set_label("conditions")
      ax.set_ylabel("scan number")
  
      ax.set_xticks(range(len(names)))
      ax.set_xticklabels(names, rotation=60, ha="left")
      # Set ticks above, to have a display more similar to the display of a
      # corresponding dataframe
      ax.xaxis.tick_top()
  
      plt.tight_layout()
      if output_file is not None:
          plt.savefig(output_file)
          plt.close()
          ax = None
      return ax
  
imports: import warnings
  import matplotlib.patches
  import matplotlib.pyplot
  import numpy
  import pandas
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  from scipy.cluster.hierarchy import leaves_list, linkage, optimal_leaf_ordering
  from nilearn.glm.first_level.experimental_paradigm import check_events
  from .._utils import fill_doc
label_desc: Use image node_id 14 for calling a global function with example usage: plot_design_matrix(design_matrix, rescale, ax, output_file) and returns: ax