Skip to content

Instantly share code, notes, and snippets.

@vals
Created November 29, 2012 23:14
Show Gist options
  • Save vals/4172579 to your computer and use it in GitHub Desktop.
Save vals/4172579 to your computer and use it in GitHub Desktop.
loadings = pca.components_
# I've omitted the code to create ind; a list of the indexes of the
# loadings ordered by distance from origin.
plt.scatter(*loadings, alpha=0.3, label="Loadings");
plt.scatter(*loadings[:, ind[:3]], c='r', marker='o',
s=80, linewidths=1, facecolors="none",
edgecolors='r',
label="Contributes most\nto variance");
plt.title("Loading plot");
plt.xlabel("Loadings on PC1");
plt.ylabel("Loadings on PC2");
plt.grid();
plt.legend(loc='lower left');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment