Skip to content

Commit

Permalink
Using alpha in the scatter plot to better see the distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyfix committed May 22, 2019
1 parent 9c970d7 commit 16c602d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions recipes/DR/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def transform(self, Z):

## Plot
plt.figure()
plt.scatter(X[:,0], X[:,1])
plt.scatter(X[:,0], X[:,1], alpha = .25)
## Plot the first projecton axis in green
plt.plot([pca.centroid[0]-2*pca.eigvecs[0, -1], pca.centroid[0]+2*pca.eigvecs[0,-1]],
[pca.centroid[1]-2*pca.eigvecs[1, -1], pca.centroid[1]+2*pca.eigvecs[1,-1]],
Expand Down Expand Up @@ -146,7 +146,7 @@ def transform(self, Z):
### the color shows how the digits get separated by the principal vectors
ax = fig.add_subplot(gs[0:2, :-2])
cmap = get_cmap(10)
ax.scatter(X_trans[:, -1], X_trans[:,-2] , c=[cmap(l) for l in y])
ax.scatter(X_trans[:, -1], X_trans[:,-2] , c=[cmap(l) for l in y], alpha = .25)
ax = fig.add_subplot(gs[0:2, -2:])
ax.set_axis_off()
for i in range(10):
Expand Down

0 comments on commit 16c602d

Please sign in to comment.