Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Quiverkey: Scaling with xy data not possible? #13616

Closed
@maximweb

Description

@maximweb

Bug report

Bug summary

I am trying to set the absolute quiverkey arrow-length matching a specific arrow-length of my quiver data. Unfortunately this seems to be impossible.

Code for reproduction

I've slightly modified the example from: matplotlib.org

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()

Actual outcome

The resulting figure looks like this: small scale figure
However, if I increase the figure window size the quiverkey does not scale with my data: maximized figure

Expected outcome

I would like to have the same scaling options for quiverkey as exist for quiver. Or even better: Inherit the properties from quiver so that the quiverkey parameter "U" gives an arrow with identical length regarding the scaling of the original quiver plot.

Matplotlib version

  • Operating system: Ubuntu 18.04 LTS
  • Matplotlib version: 3.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.5
  • Numpy version: 1.14.3

Python installation via apt-get packages and matplotlib installation using pip.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions