Ordered list of numbers is the algebraic interpretation of a vector; the geometric interpretation of a vector is a straight line with a specific length (also called magnitude) and direction (also called angle; it is computed relative to the positive x-axis).
References
Cohen, Mike X. Practical Linear Algebra for Data Science (p. 24). O'Reilly Media. Kindle Edition.
Code From the Book
# import libraries
import numpy as np
import matplotlib.pyplot as plt
# NOTE: these lines define global figure properties used for publication.
import matplotlib_inline.backend_inline
matplotlib_inline.backend_inline.set_matplotlib_formats('svg') # display figures in vector format
plt.rcParams.update({'font.size':14}) # set global font size
# create a vector
v = np.array([-1,2])
# plot that vector (and a dot for the tail)
plt.arrow(0,0,v[0],v[1],head_width=.1,width=.01)
plt.plot(0,0,'ko',markerfacecolor='k',markersize=7)
# add axis lines
plt.plot([-3,3],[0,0],'--',color=[.8,.8,.8],zorder=-1)
plt.plot([0,0],[-3,3],'--',color=[.8,.8,.8],zorder=-1)
# make the plot look nicer
plt.axis('square')
plt.axis([-3,3,-3,3])
plt.xlabel('')
plt.ylabel('')
plt.title('Vector v in standard position')
plt.show()
No comments:
Post a Comment