4

I am plotting two charts. One bar chart with matplotlib.pyplot and a second candle chart with mplfinance and I want to show them stacked on top of one another in the same figure (image).

I have found examples of how to stack plots done with matplotlib.pyplot, but can't seem to find any examples of how to join the output of two plotting libs into a single plot.

Is this possible and if so how do I go about it?

Thanks for your time.

Daniel Goldfarb
  • 6,937
  • 5
  • 29
  • 61
user2109254
  • 1,709
  • 2
  • 30
  • 49
  • It seems you cannot access to ax object in using mplfinance (plot function creates its own figure and axes) and the only way to a add a chart is to use `make_addplot` function before `plot` function. – david Apr 14 '20 at 13:24
  • It seems to be work in progress [Issue 17](https://github.com/matplotlib/mplfinance/issues/17). Until it is fixed, you can try to save your mplfinance plot and load it as an image in matplotlib. – TheIdealis Apr 14 '20 at 18:48
  • Thanks guys, I will do some research around your suggestions. – user2109254 Apr 14 '20 at 22:44

1 Answers1

1

first Customize Axis using matplotlib and you can adding Axis in mplfinance, use "ax" option for example :

import matplotlib.pyplot as plt
import mplfinance as mpf
import pandas as pd


ax = plt.subplot() 

#ax.scatter(dates, somevalues)



quotes = pd.read_csv("example.csv")

mpf.plot(quotes, type="candle", ax=ax)
Robox404
  • 7
  • 5
  • Now that mplfinance supports passing in an external axes, this is the correct answer. However there are some subtlties regarding style (colors, fonts, etc). I suggest carefully reading the documentaion [**here**](https://github.com/matplotlib/mplfinance/blob/master/markdown/subplots.md#external-axes-method) and [**here**](https://github.com/matplotlib/mplfinance/blob/master/examples/external_axes.ipynb) – Daniel Goldfarb Sep 24 '20 at 16:50