code: def plot_loadings(
      loadings,
      col_names=None,
      row_names=None,
      loading_pairs=None,
      percent_variance=None,
      title="Factor patterns",
  ):
      """
      Plot factor loadings in 2-d plots
  
      Parameters
      ----------
      loadings : array like
          Each column is a component (or factor)
      col_names : a list of strings
          column names of `loadings`
      row_names : a list of strings
          row names of `loadings`
      loading_pairs : None or a list of tuples
          Specify plots. Each tuple (i, j) represent one figure, i and j is
          the loading number for x-axis and y-axis, respectively. If `None`,
          all combinations of the loadings will be plotted.
      percent_variance : array_like
          The percent variance explained by each factor.
  
      Returns
      -------
      figs : a list of figure handles
      """
      k_var, n_factor = loadings.shape
      if loading_pairs is None:
          loading_pairs = []
          for i in range(n_factor):
              for j in range(i + 1, n_factor):
                  loading_pairs.append([i, j])
      if col_names is None:
          col_names = ["factor %d" % i for i in range(n_factor)]
      if row_names is None:
          row_names = ["var %d" % i for i in range(k_var)]
      figs = []
      for item in loading_pairs:
          i = item[0]
          j = item[1]
          fig = plt.figure(figsize=(7, 7))
          figs.append(fig)
          ax = fig.add_subplot(111)
          for k in range(loadings.shape[0]):
              plt.text(
                  loadings[k, i],
                  loadings[k, j],
                  row_names[k],
                  fontsize=12,
              )
          ax.plot(loadings[:, i], loadings[:, j], "bo")
          ax.set_title(title)
          if percent_variance is not None:
              x_str = "{} ({:.1f}%)".format(
                  col_names[i], percent_variance[i]
              )
              y_str = "{} ({:.1f}%)".format(
                  col_names[j], percent_variance[j]
              )
              ax.set_xlabel(x_str)
              ax.set_ylabel(y_str)
          else:
              ax.set_xlabel(col_names[i])
              ax.set_ylabel(col_names[j])
          v = 1.05
          xlim = np.array([-v, v])
          ylim = np.array([-v, v])
          ax.plot(xlim, [0, 0], "k--")
          ax.plot([0, 0], ylim, "k--")
          ax.set_aspect("equal", "datalim")
          ax.set_xlim(xlim)
          ax.set_ylim(ylim)
          fig.tight_layout()
      return figs
  
imports: import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: plot_loadings(loadings, col_names, row_names, loading_pairs, percent_variance, title) and returns: figs