matplotlib / matplotlib/matplotlib

[Bug]: pyplot.quiverkey does not work as expected with polar subplots

Open
#26,748 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: polar
Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

### Bug summary

`pyplot.quiverkey` does not work correctly in polar plots.

### Code for reproduction

```python
import numpy as np
from matplotlib import pyplot as plt

fig, ax = plt.subplots(subplot_kw={"polar": True})

longitude = np.arange(0, 360, 10)
colatitude = 90 - np.ones_like(longitude) * 60

sample_x = np.ones_like(longitude) # Northward
sample_y = np.zeros_like(longitude) # Eastward

q = ax.quiver(np.radians(longitude), colatitude, sample_y, -sample_x, angles="xy")
ax.quiverkey(q, X=0, Y=0, U=5, label='5 units')
```

### Actual outcome

![Unknown](https://github.com/matplotlib/matplotlib/assets/1693743/db2c1de1-2c95-4d47-859a-4c51950e42f3)

### Expected outcome

The quiverkey should be a single line rather than a cartwheel.

### Additional information

_No response_

### Operating system

macOS Ventura 13.5

### Matplotlib Version

3.7.1

### Matplotlib Backend

Installed osx event loop hook. MacOSX

### Python version

3.10.11

### Jupyter version

4.0.1

### Installation

conda

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with a polar subplot and inspect the pyplot.quiverkey path and related quiver-key handling. Compare the polar result with a non-polar plot; done means the polar quiver key renders as one line rather than a cartwheel while preserving the expected 5-unit label.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.