Last active
December 19, 2018 16:19
-
-
Save RyotaBannai/ab39c0cf37b4bb9400e8de0e3a661a64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ax = plt.gca() | |
ax.set_xlabel('Principal component 1') | |
ax.set_ylabel('Principal component 2') | |
plt.scatter(T[:, 0], T[:, 1], c='#663399', alpha=0.5) | |
plt.scatter(T_mean[0], T_mean[1], c='red', s=50) | |
for length, vector in zip(w_12_T, v_12_T): | |
dir_ = vector * 3 * np.sqrt(length) | |
arrowprops = dict(arrowstyle='->', linewidth=2, shrinkA=0, | |
shrinkB=0, color='red', alpha=0.5) | |
dir_[0] = -dir_[0] | |
start = X_mean; end = start + dir_ | |
ax.annotate('', xy = end, xytext = start, arrowprops=arrowprops) | |
#plt.axis('equal') <-- '''Let the plot scale by axes''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment