Solvedmplfinance mpf and subplots

Hi Daniel!
Thank you for your work to improve mplfinance!
How can I use MPF in old code (I write it by analogy):
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1)
mpf.plot(df, type='candle', ax=ax1)

41 Answers

✔️Accepted Answer

Hi Daniel;

I think the ability to add a subplot or a custom indicator to the plot is extremely important, especially for algorithm developers. I create unique indicators all the time and not having a subplot ability would be quite detrimental. In fact, I found this thread after attempting to plot a variation of RSI with mplfinance without success.

Other Answers:

Hi Daniel, wonderful work, thanks so much. Just wanted to add some thoughts.

I second the need for adding additional subplots. Effectively I believe we all are trying to get to this view:
image

Seems like there are two approaches to consider:

  1. mplfinance owns figure/subplots and you can simply request to add another one below with new data to be plotted. This way you can continue applying all the magic behind the scenes to ease the usage of the library.
  2. mplfinance generates subplots of candlesticks etc. and returns them to the user who is responsible for embedding them in another figure. The pro here is that you can build more complicated figures that just happen to contain price charts.

I believe there is value in both modes, and they can coexist. Imho this feature is essential, I reckon very few traders make decisions based on price chart alone, or would go into trouble of programming to just display price chart with one indicator.

Good luck!

Related Issues:

13
mplfinance mpf and subplots
Hi Daniel; I think the ability to add a subplot or a custom indicator to the plot is extremely impor...
3
mplfinance Feature Request: Remove axes completely - show data only
@MatteoSid Matteo The basic idea is you can make some things disappear by setting them to the same c...
122
ta lib Failed to install ta-lib
Here are my instructions to build the 64-bit ta-lib I tried to install ta-lib but only to fail How c...
21
pandas datareader data_source='yahoo': reading data fails since July 01
Hello all Since 2021-07-01 reading data from Yahoo fails with a nondescript error message ...
14
alpha_vantage Alpha Vantage API Review
@wickenden-g Thank you very much for your incredible review Sadly I am not related to Alpha Vantage ...
7
pandas datareader _get_response without headers doesn't work (at least with 'yahoo' source
No change to pandas_datareader code is required to fix I put in base.py: ...
4
pandas datareader AlphaVantage raises "Please input a valid date range" for previously working code
This is the error message I see So I drill into the library file and see what when wrong ...
3
ta lib TA lib installs from pip but not from github setup.py, but from pip does have some error..
Hi @mrjbq7 - So yeah I wasn't looking forward to debugging this because i knew it was going to be a ...
3
ta lib Add support for Polars Dataframe
hi @mrjbq7 author of Polars here The polars columnar data is in the apache arrow format For numerica...
23
ccxt Binance error: Timestamp for this request was 1000ms ahead of the server's time.
@jasonmellone I just synched my clock Unfortunately just synching the clock does not work ...
15
ccxt Bitfinex margin trading
Hi! Bitfinex has several types of accounts including an exchange account and a margin account ...
14
yfinance json.decoder.JSONDecodeError
Fixed with 0.1.62 Please upgrade using pip install -U yfinance Hi I am using yfinance daily ...
6
yfinance Getting this Error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Having the same issue (script was still working correctly yesterday) Hallo I am keep getting an Erro...
3
ccxt insufficent margin issue when creating order
@websharp950223 yes you're right that should be sufficient I would suggest trying to place an order ...
3
ccxt Add a hasCORS boolean property to the Exchange Structure /// Webpack throws error when building in Nuxt
@kireerik @cklester So here's the solution Add the following to your config/nuxt.js file: This will ...
3
ccxt How to make binance "test" buy market order in python with ccxt?
@adam-bhaiji a quick question – are you trying to use spot orders or futures orders? The test param ...
3
ccxt Watching multiple symbols in parallel with WebSockets
@kroitor Brilliant quite pleased with that as I managed after much longer time to cook something tog...
175
matplotlib 'NSWindow drag regions should only be invalidated on the Main Thread!' - macos/python
If you are running a webserver and using it to save Matplotlib make sure to set the backend to a non...
118
matplotlib Getting "No module named '_tkinter'" error
Oh that is easy to fix then If you didn't install tk in your python then you can not use the tk back...
72
matplotlib Segmentation fault (core dumped) when import matplotlib.pyplot
@arisliang See this section in the documentation :) The easiest way might be After updates of basica...
29
seaborn relplot error when using str as hue
This is my first time ever commenting on an open issue so please be kind if I am wrong! I was facing...
21
matplotlib error import matplotlib.pyplot as plt
This is what I did on Windows to make pyplot work pip uninstall matplotlib python -m pip install --u...
17
ipympl notebook backend not working in jupyterlab
In case others get here and are a little confused: At the beginning of your notebook run %matplotlib...
17
seaborn The solution of display chinese in seaborn plot
Thanks @githubzhanglei it works fine under python 3 here is my result Just to be sure to set mpl fir...
16
matplotlib ImportError: No module named artist
Your installation is broken reinstalling mpl via conda If this does not work try the mpl user mailin...
13
matplotlib Installation on CentOS using pip in virtualenv
These commands worked for me on a fresh CentOS 7 container: Bug summary running pip install matplotl...
12
matplotlib plt.plot() terminating with uncaught exception of type NSException
If I try to use Qt5Agg I get the following error: However quite surprisingly if I explicitly tell ma...
12
seaborn Is the markers parameter in scatterplot() not implemented?
Yes I did read the error message I was hoping to gain some insight on the inconsistent behaviour bet...
6
yellowbrick ImportError: cannot import name 'safe_indexing' from 'sklearn.utils'
Hi @Paulj1989 and thanks for letting us know! It looks like scikit-learn has again changed their pub...
5
seaborn one kdeplot function error of seaborn
@PyAntony update your statsmodels package to 0.8.0 pip install -U statsmodels should do the trick ...