matplotlib / matplotlib/matplotlib

[Bug]: quiver plotting behaves bizarrely with polar plots

Open
#26,750 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

### Bug summary

There is no documentation, as far as I can tell, explaining how quiver should behave with polar plots, and using `pyplot.quiver` with a polar plot results in odd plotting behaviour.

### 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(5, 365, 10)
colatitude = 90 - np.ones_like(longitude) * 60

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

q = ax.quiver(np.radians(longitude), colatitude, sample_x, sample_y, angles="xy")
```

### Actual outcome

![Unknown-2](https://github.com/matplotlib/matplotlib/assets/1693743/f2a60f24-a667-48ad-92bd-4de154d4e8b4)

### Expected outcome

I would expect the code to plot arrows which were vectors pointing all pointing northeast; i.e., I expect `sample_x` to be defined as the northward (poleward) vector and `sample y` to be defined as the eastward (azimuthal) vector.

### 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 reproduction with matplotlib.pyplot.quiver on a polar Axes. Trace how the polar coordinates and the angles="xy" vectors are interpreted, then verify that the resulting arrows match the requested northward and eastward components. Done means the behavior is corrected or clearly documented, with a regression check for this example.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.