def test_transform(self): for tfm in [None, ILRTransform, ALRTransform]: with self.subTest(tfm=tfm): if callable(tfm): T = tfm() comp = T.transform(self.comp3d) transform = T.inverse_transform else: transform = None comp = self.comp2d plot_pca_vectors(comp, transform=transform)
comp.loc[:, chem].pyroplot.scatter(ax=ax[0], c=t10b3[ix], **kwargs) plt.show() ####################################################################################### # We can take the mean and covariance in log-space to create covariance ellipses and # vectors using principal component analysis: # kwargs = dict(ax=ax[1], transform=from_log, nstds=3) ax[1].set_title("Covariance Ellipses and PCA Vectors") for ix, sample in enumerate(df.Sample.unique()): comp = df.query("Sample == {}".format(sample)) tcomp = to_log(comp.loc[:, chem]) plot_stdev_ellipses(tcomp.values, color=t10b3[ix], resolution=1000, **kwargs) plot_pca_vectors(tcomp.values, ls="-", lw=0.5, color="k", **kwargs) plt.show() ####################################################################################### # We can also look at data density (here using kernel density estimation) # in logratio-space: # kwargs = dict(ax=ax[-2], bins=100, axlabels=False) ax[-2].set_title("Individual Density, with Contours") for ix, sample in enumerate(df.Sample.unique()): comp = df.query("Sample == {}".format(sample)) comp.loc[:, chem].pyroplot.density(cmap="Blues", vmin=0.05, **kwargs) comp.loc[:, chem].pyroplot.density( contours=[0.68, 0.95], cmap="Blues_r", contour_labels={
def test_default(self): for comp in [self.comp2d, self.comp3d]: with self.subTest(comp=comp): plot_pca_vectors(comp)
def test_axis_specified(self): for comp in [self.comp2d, self.comp3d]: with self.subTest(comp=comp): fig, ax = plt.subplots() plot_pca_vectors(comp, ax=ax)