def pca_plot(pca, dt, xlabs=None, mode='<STR_LIT>', lognorm=True):
nc = pca.n_components<EOL>f = np.arange(pca.n_features_)<EOL>cs = list(itertools.combinations(range(nc), <NUM_LIT:2>))<EOL>ind = ~np.apply_along_axis(any, <NUM_LIT:1>, np.isnan(dt))<EOL>cylim = (pca.components_.min(), pca.components_.max())<EOL>yd = cylim[<NUM_LIT:1>] - cylim[<NUM_LIT:0>]<EOL>fig, axs = plt.subplots(nc, nc, figsize=[<NUM_LIT:3> * nc, nc * <NUM_LIT:3>], tight_layout=True)<EOL>for x, y in zip(*np.triu_indices(nc)):<EOL><INDENT>if x == y:<EOL><INDENT>tax = axs[x, y]<EOL>tax.bar(f, pca.components_[x], <NUM_LIT>)<EOL>tax.set_xticks([])<EOL>tax.axhline(<NUM_LIT:0>, zorder=-<NUM_LIT:1>, c=(<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT>))<EOL>tax.set_ylim(cylim[<NUM_LIT:0>] - <NUM_LIT> * yd,<EOL>cylim[<NUM_LIT:1>] + <NUM_LIT> * yd)<EOL>for xi, yi, lab in zip(f, pca.components_[x], xlabs):<EOL><INDENT>if yi > <NUM_LIT:0>:<EOL><INDENT>yo = yd * <NUM_LIT><EOL>va = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>yo = yd * -<NUM_LIT><EOL>va = '<STR_LIT>'<EOL><DEDENT>tax.text(xi, yi + yo, lab, ha='<STR_LIT>', va=va, rotation=<NUM_LIT>, fontsize=<NUM_LIT:8>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>xv = dt[ind, x]<EOL>yv = dt[ind, y]<EOL>if mode == '<STR_LIT>':<EOL><INDENT>axs[x, y].scatter(xv, yv, alpha=<NUM_LIT>)<EOL>axs[y, x].scatter(yv, xv, alpha=<NUM_LIT>)<EOL><DEDENT>if mode == '<STR_LIT>':<EOL><INDENT>if lognorm:<EOL><INDENT>norm = mpl.colors.LogNorm()<EOL><DEDENT>else:<EOL><INDENT>norm = None<EOL><DEDENT>axs[x, y].hist2d(xv, yv, <NUM_LIT:50>, cmap=plt.cm.Blues, norm=norm)<EOL>axs[y, x].hist2d(yv, xv, <NUM_LIT:50>, cmap=plt.cm.Blues, norm=norm)<EOL><DEDENT><DEDENT>if x == <NUM_LIT:0>:<EOL><INDENT>axs[y, x].set_ylabel('<STR_LIT>'.format(y + <NUM_LIT:1>))<EOL><DEDENT>if y == nc - <NUM_LIT:1>:<EOL><INDENT>axs[y, x].set_xlabel('<STR_LIT>'.format(x + <NUM_LIT:1>))<EOL><DEDENT><DEDENT>return fig, axs, xv, yv<EOL>
Plot a fitted PCA, and all components.