1

I want my mathplotlib figure to have another set of axis/lines. Currently I do as follows:

plt.plot([0,eigenVectors[0][0]],[0,eigenVectors[1][0]],color='k',marker='o')
plt.plot([0,eigenVectors[0][1]],[0,eigenVectors[1][1]],color='k',marker='o')

where eigenVector is a 2d matrix and I am just trying to draw lines passing through the eigenvectors and the origin. However, as it is evident, I am drawing two line segments not lines. I wish to draw two lines passing through origin and the eigenvectors. Is there a way to say that draw a line (not a line segment) passing through two points?

My current plot looks like this:

enter image description here

PS: I am trying to implement PCA.

Abhishek Chauhan
  • 309
  • 5
  • 15

1 Answers1

0

You could extrapolate linearly to some large values and use them to plot the lines. Then limit the plt.xlim and plt.ylim to some sensible value. For more information on the extrapolation, see this post.

Community
  • 1
  • 1
jhoepken
  • 1,842
  • 3
  • 17
  • 24
  • This draws a line segment between the two points given. I want a line, not a line segment. By line I mean it should extend indefinitely and not just confine itself between the two points. – Abhishek Chauhan Jun 24 '15 at 14:54