I'm new to python and learn to plot graph with matplotlib. I try to plot vector that point from (0, 0) to (2, 1).
import matplotlib.pyplot as plt
O = [0, 0]
V = [2, 1]
plt.quiver(O[0], O[1], V[0], V[1], units='xy', scale=1, color='r')
plt.xlim(-3, 3)
plt.ylim(-3, 3)
plt.grid()
plt.show()
My vector plot :

You should specify also the parameters:
angles = 'xy'scale_units = 'xy'Read the documentation for more information on those parameters.
Full line of code:
plt.quiver(O[0], O[1], V[0], V[1], units = 'xy', angles = 'xy', scale = 1, scale_units = 'xy', color = 'r')

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With