matplotlib / matplotlib/mplfinance

Bug Report: legends on panels overlaps

Open
#669 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
4.4k
Forks
678
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When multiple addplots exists in a panel, their label overlaps.

**To Reproduce**

```python
data["col1"] = np.random.rand(len(data))
data["col2"] = np.random.rand(len(data))

addplots = [
mpf.make_addplot(data["col1"], label="col1", panel=1),
mpf.make_addplot(data["col2"], label="col2", panel=1)
]

mpf.plot(data, type="candle", addplot=addplots)
```

**Expected behavior**
legends should be vertical stacked

**Screenshots**
![image](https://github.com/matplotlib/mplfinance/assets/575834/beddb625-cb8d-4fa5-ae8b-777aab20105a)

**Additional context**
if panel=0, it's all ok.
![image](https://github.com/matplotlib/mplfinance/assets/575834/c003e334-39ec-4887-b1d7-013a19d0ce56)

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 Python reproduction from the issue with two addplots on panel 1, then trace mplfinance's panel legend handling. Done means the labels for multiple addplots in a nonzero panel render as a vertical stack without overlap, while the existing panel 0 behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.