title: How to plot vector field on image?
body: <p>In order to understand visually the involved vector, scalar fields of an image operation which involves calculating, gradient, divergence, laplacian etc, I am trying to plot them also on the image involved. I started with gradient as below, but </p>
  
  <ol>
  <li>getting the arrow set rotated (looks like so), compared to image underneath. What am I missing?</li>
  <li>Also how do I scale them nicely? </li>
  </ol>
  
  <p>MWE:</p>
  
  <pre><code>test_img = cv2.imread('images/ring.png', cv2.IMREAD_GRAYSCALE)
  r, c = test_img.shape
  gd = 15
  
  test_slice = test_img[::gd,::gd]  # every 15th point
  
  X, Y = np.mgrid[0:r:gd, 0:c:gd]
  dY, dX = np.gradient(test_slice)
  
  plt.figure(figsize=(10,10))
  plt.quiver(X, Y, dX, dY, color='y')
  plt.imshow(test_img, cmap='gray')
  plt.show()
  </code></pre>
  
  <p><strong>Output</strong>:  </p>
  
  <p><a href="https://i.stack.imgur.com/gUIW7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUIW7.png" alt="enter image description here"></a></p>
  
  <p><strong>Desired style</strong> : (vector field with image underneath instead):</p>
  
  <p><a href="https://i.stack.imgur.com/KF80k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KF80k.png" alt="enter image description here"></a></p>
  
  <p><strong>Sample Image used:</strong> <a href="https://i.postimg.cc/L8m3q6VK/ring-owhite.jpg" rel="nofollow noreferrer">link</a></p>
  
  <p>Note: I initially used a png, then then alpha area was giving a nan, so now I have the jpg uploaded. </p>