matplotlib / matplotlib/mplfinance
Feature Request:addplot does not take dataframe index
Nobody has claimed this yet.
- 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.

Please allow addplot to have its own x values as the index of the input dataframe.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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