Last active
May 12, 2019 12:39
-
-
Save tanveer-sayyed/90b81a3bf6c5abb96c495c905749d072 to your computer and use it in GitHub Desktop.
new function Plot_All
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
def Plot_All(A, eigenvectors): | |
plt.figure(figsize=(12,3)) | |
plt.subplot(1,3,1) | |
V = [np.array([[0, 0]]), [eigenVectors]] # padded [0,0] just to get the pink colour | |
for i in range(len(V)): | |
for j in range(len(V[i])): | |
plt.quiver(*([0],[0]), V[i][j][0], V[i][j][1], angles='xy', scale_units='xy', scale=1, color=plt.cm.Paired((i+3)/10.)) | |
plt.grid(b=True, which='major', linestyle= ':') | |
plt.xticks(np.arange(-5, 5 + 1, 1)) | |
plt.yticks(np.arange(-5, 5 + 1, 1)) | |
plt.title('Eigenvectors') | |
plt.subplot(1,3,2) | |
outVector = A.dot(eigenVectors[:,0]) | |
V = [[outVector], [eigenVectors[:,0]]] | |
for i in range(len(V)): | |
for j in range(len(V[i])): | |
plt.quiver(*([0],[0]), V[i][j][0], V[i][j][1], angles='xy', scale_units='xy', scale=1, color=plt.cm.Paired((i+3)/10.)) | |
plt.grid(b=True, which='major', linestyle= ':') | |
plt.xticks(np.arange(-5, 5 + 1, 1)) | |
plt.yticks(np.arange(-5, 5 + 1, 1)) | |
plt.title('A applied on e0') | |
plt.subplot(1,3,3) | |
outVector = A.dot(eigenVectors[:,1]) | |
V = [[outVector], [eigenVectors[:,1]]] | |
for i in range(len(V)): | |
for j in range(len(V[i])): | |
plt.quiver(*([0],[0]), V[i][j][0], V[i][j][1], angles='xy', scale_units='xy', scale=1, color=plt.cm.Paired((i+3)/10.)) | |
plt.grid(b=True, which='major', linestyle= ':') | |
plt.xticks(np.arange(-5, 5 + 1, 1)) | |
plt.yticks(np.arange(-5, 5 + 1, 1)) | |
plt.title('A applied on e1') | |
# because eigenvector is a vector on a line we can choose | |
# any suitable point "we want" on that line! | |
def Scaling_Eigen_Vectors(eigenVectors): | |
for i in range(len(eigenVectors)): | |
eigenVectors[:,i] = eigenVectors[:,i] / np.absolute(min(eigenVectors[:,i])) | |
return eigenVectors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment