matplotlib / matplotlib/mplfinance

Feature Request:addplot does not take dataframe index

Open
#323 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I would like to plot two data as below.

```
plot2 = mpf.make_addplot(data2, type='candle')
mpf.plot(data, type='candle', addplot=plot2)
```

However, the problem is that data2 contains 3 candles and data contains 4 candles with different indices.

data2.index
`['2021-01-05', '2021-01-06', '2021-01-07']`

data.index
`['2021-01-04', '2021-01-05', '2021-01-06', '2021-01-07']`

Despite the fact that the time index of data2 starts from 2021-01-05, the plot starts from 2021-01-04
You can see three overlapped candles on 01-04, 01-05, 01-06.
![Selection_007](https://user-images.githubusercontent.com/34349131/105678422-7b803200-5f30-11eb-8e16-3b1d0553c1ef.png)

Please allow addplot to have its own x values as the index of the input dataframe.

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 reproducing the reported example with mpf.make_addplot() and mpf.plot(), using the two dataframes and their differing indices. Inspect how addplot data is positioned relative to the main plot's x values. Done means addplot uses its input dataframe index so the three candles align with 2021-01-05 through 2021-01-07 rather than starting at 2021-01-04.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Feature
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.