matplotlib / matplotlib/matplotlib

bad autoscale_view() with long curved FancyArrowPatch

Open
#19,723 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

keep status: confirmed bug topic: arrow
Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

### Bug report

When using a very long `FancyArrowPatch` with `connectionstyle="arc3"`, subsequent axes autoscaling can badly squash the figure's content. Example below exhibits the problem, but more extreme squashing can easily be obtained. Possibly this is not limited to `FancyArrowPatch`?

**Code for reproduction**

```python
import matplotlib
import matplotlib.pyplot as plt

fap = matplotlib.patches.FancyArrowPatch(
(10, 10),
(20, 2e4),
mutation_scale=50,
connectionstyle="arc3,rad=0.3",
)

_, ax = plt.subplots()
ax.add_patch(fap)
ax.set_title(f"matplotlib {matplotlib.__version__}")
ax.autoscale_view()
ax.figure.savefig("curved-arrow.png")
```

**Actual outcome**

![curved-arrow](https://user-images.githubusercontent.com/8665077/111459663-45cf1c80-871b-11eb-9255-cf475ef1725b.png)

**Expected outcome**

The axes view should span the drawn content. Any control point(s) required for the arc should be ignored.

**Matplotlib version**

* Operating system: Linux
* Matplotlib version: 3.3.4
* Matplotlib backend: Reproducible with at least `GTK3Agg` and `agg`.
* Python version: 3.9

Matplotlib installed via pip.

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 with the reproduction code using FancyArrowPatch, connectionstyle="arc3", and ax.autoscale_view(), then trace the FancyArrowPatch and autoscale_view entry points. Confirm the behavior with the supplied example and determine how control points affect the calculated view limits. Done means the axes span the drawn content without being badly squashed, with regression coverage for the 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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.