Reputation: 47
I want to connect two points in a 2D view with an arrow, but when I use ax.quiver or ax.arrow, it does not work for my points. The two points are(485.0, 759.0) and (485.0, 764.0) here is my code:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(2)
ax = fig.add_subplot(111)
ax.quiver(485.0, 759.0, 485.0, 764.0,angles='xy', scale_units='xy', scale = 1)
ax.axis([400, 500, 600, 800])
plt.grid()
plt.draw()
plt.show()
from the graph seems the end point does not make sense. enter image description here
Upvotes: 0
Views: 1368
Reputation: 65460
The third and fourth inputs to quiver
are the length of the arrow in the x and y directions not the x and y coordinates of the head of the arrow. You'll instead want to subtract the end point from the start point to get the lengths
ax.quiver(485.0, 759.0, 485.0 - 485.0, 764.0 - 759.0,
angles='xy', scale_units='xy', scale = 1)
Upvotes: 1