superimpose matplotlib quiver on image superimpose matplotlib quiver on image numpy numpy

superimpose matplotlib quiver on image


If you want to have the same plot orientation that you get with plotting the arrows alone, you can change the origin of the image by adding origin='lower' to the imshow call:

plt.imshow(test_array, origin='lower')

If you want to keep the image origin in the upper left corner, you could just change the direction of the arrows when you call plt.quiver:

dy, dx = np.gradient(test_array)plt.imshow(test_array)plt.quiver(dx, -dy)plt.show()