code: def dendrogram(
      df,
      method="average",
      filter=None,
      n=0,
      p=0,
      orientation=None,
      figsize=None,
      fontsize=16,
      label_rotation=45,
      ax=None,
  ):
      """
      Fits a `scipy` hierarchical clustering algorithm to the given DataFrame's variables and visualizes the results as
      a `scipy` dendrogram.
  
      The default vertical display will fit up to 50 columns. If more than 50 columns are specified and orientation is
      left unspecified the dendrogram will automatically swap to a horizontal display to fit the additional variables.
  
      :param df: The DataFrame whose completeness is being dendrogrammed.
      :param method: The distance measure being used for clustering. This is a parameter that is passed to
          `scipy.hierarchy`.
      :param filter: The filter to apply to the heatmap. Should be one of "top", "bottom", or None (default).
      :param n: The cap on the number of columns to include in the filtered DataFrame.
      :param p: The cap on the percentage fill of the columns in the filtered DataFrame.
      :param figsize: The size of the figure to display. This is a `matplotlib` parameter which defaults to `(25, 10)`.
      :param fontsize: The figure's font size.
      :param orientation: The way the dendrogram is oriented. Defaults to top-down if there are less than or equal to 50
          columns and left-right if there are more.
      :param label_rotation: What angle to rotate the text labels to. Defaults to 45 degrees.
      :return: The plot axis.
      """
      if not figsize:
          if (
              len(df.columns) <= 50
              or orientation == "top"
              or orientation == "bottom"
          ):
              figsize = (25, 10)
          else:
              figsize = (25, (25 + len(df.columns) - 50) * 0.5)
  
      if ax is None:
          plt.figure(figsize=figsize)
          ax0 = plt.gca()
      else:
          ax0 = ax
  
      df = nullity_filter(df, filter=filter, n=n, p=p)
  
      # Link the hierarchical output matrix, figure out orientation, construct base dendrogram.
      x = np.transpose(df.isnull().astype(int).values)
      z = hierarchy.linkage(x, method)
  
      if not orientation:
          if len(df.columns) > 50:
              orientation = "left"
          else:
              orientation = "bottom"
  
      hierarchy.dendrogram(
          z,
          orientation=orientation,
          labels=df.columns.tolist(),
          distance_sort="descending",
          link_color_func=lambda c: "black",
          leaf_font_size=fontsize,
          ax=ax0,
      )
  
      # Remove extraneous default visual elements.
      ax0.set_aspect("auto")
      ax0.grid(visible=False)
      if orientation == "bottom":
          ax0.xaxis.tick_top()
      ax0.xaxis.set_ticks_position("none")
      ax0.yaxis.set_ticks_position("none")
      ax0.spines["top"].set_visible(False)
      ax0.spines["right"].set_visible(False)
      ax0.spines["bottom"].set_visible(False)
      ax0.spines["left"].set_visible(False)
      ax0.patch.set_visible(False)
  
      # Set up the categorical axis labels and draw.
      if orientation == "bottom":
          ax0.set_xticklabels(
              ax0.xaxis.get_majorticklabels(),
              rotation=label_rotation,
              ha="left",
          )
      elif orientation == "top":
          ax0.set_xticklabels(
              ax0.xaxis.get_majorticklabels(),
              rotation=label_rotation,
              ha="right",
          )
      if orientation == "bottom" or orientation == "top":
          ax0.tick_params(axis="y", labelsize=int(fontsize / 16 * 20))
      else:
          ax0.tick_params(axis="x", labelsize=int(fontsize / 16 * 20))
  
      return ax0
  
file_path: missingno/missingno/missingno.py
imports: import numpy
  import matplotlib
  from matplotlib import gridspec
  import matplotlib.pyplot
  from scipy.cluster import hierarchy
  import seaborn
  import pandas
  from .utils import nullity_filter, nullity_sort
  import warnings
label_desc: Use image node_id 4 for calling a global function with example usage: dendrogram(df, method, filter, n, p, orientation, figsize, fontsize, label_rotation, ax) and returns: ax0