code: def plot_scree(eigenvals, total_var, ncomp=None, x_label="factor"):
      """
      Plot of the ordered eigenvalues and variance explained for the loadings
  
      Parameters
      ----------
      eigenvals : array_like
          The eigenvalues
      total_var : float
          the total variance (for plotting percent variance explained)
      ncomp : int, optional
          Number of factors to include in the plot.  If None, will
          included the same as the number of maximum possible loadings
      x_label : str
          label of x-axis
  
      Returns
      -------
      Figure
          Handle to the figure.
      """
      fig = plt.figure()
      ncomp = len(eigenvals) if ncomp is None else ncomp
      vals = eigenvals
      vals = vals[:ncomp]
      #    vals = np.cumsum(vals)
  
      ax = fig.add_subplot(121)
      ax.plot(np.arange(ncomp), vals[:ncomp], "b-o")
      ax.autoscale(tight=True)
      xlim = np.array(ax.get_xlim())
      sp = xlim[1] - xlim[0]
      xlim += 0.02 * np.array([-sp, sp])
      ax.set_xticks(np.arange(ncomp))
      ax.set_xlim(xlim)
  
      ylim = np.array(ax.get_ylim())
      scale = 0.02
      sp = ylim[1] - ylim[0]
      ylim += scale * np.array([-sp, sp])
      ax.set_ylim(ylim)
      ax.set_title("Scree Plot")
      ax.set_ylabel("Eigenvalue")
      ax.set_xlabel(x_label)
  
      per_variance = vals / total_var
      cumper_variance = np.cumsum(per_variance)
      ax = fig.add_subplot(122)
  
      ax.plot(np.arange(ncomp), per_variance[:ncomp], "b-o")
      ax.plot(np.arange(ncomp), cumper_variance[:ncomp], "g--o")
      ax.autoscale(tight=True)
      xlim = np.array(ax.get_xlim())
      sp = xlim[1] - xlim[0]
      xlim += 0.02 * np.array([-sp, sp])
      ax.set_xticks(np.arange(ncomp))
      ax.set_xlim(xlim)
  
      ylim = np.array(ax.get_ylim())
      scale = 0.02
      sp = ylim[1] - ylim[0]
      ylim += scale * np.array([-sp, sp])
      ax.set_ylim(ylim)
      ax.set_title("Variance Explained")
      ax.set_ylabel("Proportion")
      ax.set_xlabel(x_label)
      ax.legend(["Proportion", "Cumulative"], loc=5)
      fig.tight_layout()
      return fig
  
imports: import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: plot_scree(eigenvals, total_var, ncomp, x_label) and returns: fig