user3668129
user3668129

Reputation: 4810

quiver plot wrong vectors

I'm trying to plot 2 simple vectors with quiver and I'm getting strange plot:

import numpy as np
import matplotlib.pyplot as plt

v1 = np.array(([6,  8]))
x = np.array(([6 ,0]))

plt.quiver(v1, x, angles='xy', scale_units='xy', scale=1)
plt.xlim(-1, 10)
plt.ylim(-1, 10)
plt.show()

enter image description here

  1. Why the 2 vectors dosn't start from the origin (0, 0) ? (How can I fix it ?)
  2. According to the plot, the vectors are (6,6), (8.5, 0) and not as I wrote. Why ? How do I fix it ?

Upvotes: 0

Views: 639

Answers (1)

BigBen
BigBen

Reputation: 49998

For example:

X = [0, 0]
Y = [0, 0]
U = [6, 8]
V = [6, 0]

plt.quiver(X, Y, U, V, angles='xy', scale_units='xy', scale=1)

Output:

enter image description here

Upvotes: 2

Related Questions