title: superimpose matplotlib quiver on image
body: <p>I'm trying to superimpose quiver gradient arrows on an image, but since the origin locations are different, they don't look right. How would I fix this?</p>
  <p>This is an example. The image to the left are the gradients I expect, but as soon as I draw them on top of an image, they point in the wrong directions because of the change in origin location.</p>
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  import numpy as np
  
  test_array = np.array([[0, 0, 0, 0, 0],
                         [0, 64, 128, 64, 0],
                         [0, 127, 255, 127, 0],
                         [0, 64, 127, 64, 0],
                         [0, 0, 0, 0, 0]]).astype(&quot;float&quot;)
  
  dy, dx = np.gradient(test_array)
  plt.imshow(test_array)
  plt.quiver(dx, dy)
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/M7TV3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M7TV3.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/uZAaN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uZAaN.png" alt="enter image description here" /></a></p>