title: How to set quiverkey length scaling with xy data in matplotlib?
body: <p>I am trying to set the absolute <code>quiverkey</code> arrow-length matching a specific arrow-length of my <code>quiver</code> data. Can somebody enlighten me how the <code>quiverkey</code> argument <code>U</code> works or at least how to scale it to my needs?</p>
  
  <p><strong>Background</strong></p>
  
  <p>Python version: 3.6.5</p>
  
  <p>matplotlib version: 3.0.0</p>
  
  <p><strong>Minimal example</strong></p>
  
  <p>I've slightly modified the example from: <a href="https://matplotlib.org/gallery/images_contours_and_fields/quiver_simple_demo.html#sphx-glr-gallery-images-contours-and-fields-quiver-simple-demo-py" rel="nofollow noreferrer">https://matplotlib.org/gallery/images_contours_and_fields/quiver_simple_demo.html#sphx-glr-gallery-images-contours-and-fields-quiver-simple-demo-py</a></p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  X = np.arange(-10, 11, 2)
  Y = np.arange(-10, 11, 2)
  U, V = np.meshgrid(X, Y)
  
  # calculate length of each arrow
  data_arrow_length = np.abs(np.sqrt(np.square(U[:]) + np.square(U[:])))
  
  # set displayed arrow length for longest arrow
  displayed_arrow_length = 2
  
  # calculate scale factor for quiver
  scale_factor = np.max(data_arrow_length)/displayed_arrow_length
  
  # mysterious arrow length for quiverkey
  quiverkey_length = 200
  
  fig, ax = plt.subplots()
  q = ax.quiver(X, Y, U, V, pivot='middle',
                units='xy', width=0.1,
                scale=scale_factor, scale_units='xy')
  ax.quiverkey(q, X=0.3, Y=1.1, U=quiverkey_length,
               label='Quiver key, length = 10', labelpos='E')
  
  plt.show()
  </code></pre>
  
  <p>This way I can control the maximal arrow-length displayed with <code>quiver</code> using <code>displayed_arrow_length</code>. In this example the maximal <code>data_arrow_length</code> is approx. 14 and is displayed with an arrow length of 2 based on xy-data.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>If I run the above example I get:</p>
  
  <p><a href="https://i.stack.imgur.com/tlfGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tlfGN.png" alt="Small plot"></a></p>
  
  <p>However, if I maximize the figure window I get:</p>
  
  <p><a href="https://i.stack.imgur.com/1YBL2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1YBL2.png" alt="Large plot"></a></p>
  
  <p>The <code>quiverkey</code>arrow-length does not scale with my <code>quiver</code> arrows and I had to use an randomly high number for <code>quiverkey_length</code> to appear altogether.</p>
  
  <p><strong>Question</strong></p>
  
  <p>I would like to set the <code>quiverkey</code> arrow length to a specific value as displayed with <code>quiver</code>, for example 10. However, it does not appear to scale with the data at all. How can I achieve this?</p>