import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Create a vector
vec = np.array([[5],[4]])
print(vec)
origin = np.zeros(vec.shape)
plt.figure(figsize=(6,6))
plt.quiver(*origin, *vec, color=['r'], scale=1, units='xy')
plt.grid()
plt.xlim(-10,10)
plt.ylim(-10,10)
plt.gca().set_aspect('equal')
plt.show()
x_coord = vec[0]
y_coord = vec[1]
print("x:", x_coord)
print("y:", y_coord)
# As shown in the theory above, if we multiply vectors i and j by scalar
# we will get a vector. Let's see how we can reconstruct the original vector
# if we know the amount of movement over x and y axis.
i = np.array([[1],[0]])
j = np.array([[0],[1]])
vec_new = i*x_coord + j*y_coord
print(vec_new)