Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.mplot3d import Axes3D
- # algebraic 2-dimensional vector representation
- v1 = np.array([ 1, 2])
- # algebraic 3-dimensional vector representation
- v2 = np.array([ 1,2,3])
- # geometric representation of v1
- plt.plot([0,v1[0]],[0,v1[1]])
- plt.axis('equal')
- plt.plot([-4, 4],[0, 0],'k--')
- plt.plot([0, 0],[-4, 4],'k--')
- plt.grid()
- plt.axis((-4, 4, -4, 4))
- plt.show()
- # geometric representation of v2
- fig = plt.figure()
- ax = fig.gca(projection='3d')
- ax.plot([0, v2[0]],[0, v2[1]],[0, v2[2]])
- # make the plot look nicer
- plt.axis('equal')
- ax.plot([0, 0],[0, 0],[-4, 4],'k--')
- ax.plot([0, 0],[-4, 4],[0, 0],'k--')
- ax.plot([-4, 4],[0, 0],[0, 0],'k--')
- plt.show()
Add Comment
Please, Sign In to add comment