matplotlib / matplotlib/mplfinance
Have a problem, when I work with external_axes.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 678
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I need to add to the plot some text and I tried to use your guide "How to use your own matplotlib Figure and Axes in mplfinance". But i have an error:
"ValueError: make_addplot() `ax` kwargs must all be of type `matplotlib.axis.Axes`"
My code:
```
import mplfinance as fplt
import pandas as pd
df5M = pd.read_csv("D:\\_users_files\\Kirill\\WORK\\fx2youcom\\df5M.csv", index_col=0, parse_dates=True)
fig = fplt.figure(style='yahoo', figsize=(10.8, 6.4))
ax1 = fig.add_subplot(2, 2, 1)
sma = [fplt.make_addplot(df5M['SMA20'].tail(100), color='#f1afe1'),
fplt.make_addplot(df5M['SMA50'].tail(100), color='#ffaf6c'),
fplt.make_addplot(df5M['SMA200'].tail(100), color='#f0dea7')]
fplt.plot(df5M.tail(100),
type='candle',
ax=ax1,
style='yahoo',
title="long_name",
ylabel='5 Minutes',
addplot=sma
)
fig
```
Thank you for help, you do really helpful framework!
Contributor guide
Research direction
Start with the guide "How to use your own matplotlib Figure and Axes in mplfinance" and reproduce the example using make_addplot() with the external ax1 passed to fplt.plot(). Trace the validation that raises the matplotlib.axis.Axes error, then verify that the supplied figure and axes work with the SMA addplots and candle plot as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, pandas, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100