Reputation: 584
I have a very simple cell of code that draws a single vector with pyplot.quiver
. It should start at (0,0)
and stretch to (1,1)
. However, the arrow is clearly not directed to (1,1)
.
The documentation says that, with the call signature:
quiver([X, Y], U, V, [C], **kw)
X, Y define the arrow locations, U, V define the arrow directions, and C optionally sets the color.
What is happening here?
import numpy as np
import matplotlib.pyplot as plt
plt.quiver(0,0,1,1, scale=5)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.grid()
plt.show()
Upvotes: 1
Views: 387
Reputation: 12524
Referring to the documentation, you should specify angles
, scale_units
and scale
parameters in order to tell matplotlib you want to refer to (x, y) coordinates and units:
ax.quiver(0, 0, 1, 1, angles = 'xy', scale_units = 'xy', scale = 1)
Upvotes: 2