title: How to plot largest and smallest eigen vectors, for 2-dimensional data using numpy and matplotlib in python?
body: <p><strong>Summary:</strong></p>
  
  <p>I am trying to plot the largest and smallest eigen vectors of 2-dimensional data in python using numpy and matplotlib. I used the numpy functions for covariance matrix, eigen values and eigen vectors. Later, I tried to plot the eigen vectors using quiver plot for the given data. The eigen vectors do not show up correctly. I guess there is some mistake in the way in which I am plotting the quiver plot. Can someone guide me what is the right way ?</p>
  
  <p><strong>This is my code :</strong></p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from numpy import array
  from numpy import linalg as LA
  
  # Assume that I loaded 'N' no of 2d points from a file and used
  # np.cov() to find the below covariance matrix
  
  # This is my covariance matrix obtained from 2 x N points
  cov_mat = [[3407.3108669  1473.06388943]
             [1473.06388943 1169.53151003]]
  
  eigen_values, eigen_vectors = LA.eig(cov_mat)
  
  origin = [0, 0]
  
  eig_vec1 = eigen_vectors[:,0]
  eig_vec2 = eigen_vectors[:,1]
  
  # This line below plots the 2d points
  #plt.scatter(np_array[:,0], np_array[:,1])
  
  plt.quiver(origin, eig_vec1, color=['r'], scale=21)
  plt.quiver(origin, eig_vec2, color=['b'], scale=21)
  plt.show()
  </code></pre>
  
  <p><strong>My Output:</strong></p>
  
  <p>This is my 2D data. We can see the largest eigen vector is supposed to be in the diagonal direction. But the vector does not show up correctly in the plot.</p>
  
  <p><img src="https://i.stack.imgur.com/HtghR.png" alt="Numpy_Image"></p>