Max Linke
Max Linke

Reputation: 1745

Draw arrows over points

How can I draw quivers in a matplotlib figure so that they are drawn over the original points.

soa = np.array([vec1,vec2])
X,Y,U,V = zip(*soa)
ax = plt.gca()
ax.plot(ax, rotdata[:,0], rotdata[:,1], 'o', c='b')
ax.quiver(X,Y,U,V, angles='xy', scale_units='xy',scale=1,
          width=.02, color='r')

I get this with the code above.

result

This is the result I would like to have

desired result

Upvotes: 0

Views: 1110

Answers (1)

GCien
GCien

Reputation: 2349

You need to specify an order for both the data points and the arrows by using the zorder kwarg as follows:

soa = np.array([vec1,vec2])
X,Y,U,V = zip(*soa)
ax = plt.gca()

ax.plot(ax, rotdata[:,0], rotdata[:,1], 'o', c='b', zorder=1)
ax.quiver(X,Y,U,V, angles='xy', scale_units='xy',scale=1,
      width=.02, color='r',zorder=2)

Upvotes: 2

Related Questions