-
Notifications
You must be signed in to change notification settings - Fork 657
Feature Request: stack another indicator on the mpf.plot() with axes.twinx() #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did you read the documentation? Please read, completely, the following, in this order, and then see if maybe your question is answered:
Thanks. All the best. --Daniel |
Hi Daniel,
this is what i get after setting secondary y axis, but still have the candlestick at the bottom. |
@ggg5269 (That said, as a general rule I would strongly recommend against creating and using Figure and Axes, as you are, unless you are trying to accomplish something that is otherwise not supported by mplfinance; however it appears to me that what you are trying to do is definitely supported by a simple use of So in order to help you solve this problem, I would need to see the data you are using, and the code that processes the data. Please attach you data (preferably as csv files, or as whatever format you are using), and include also all of the code that prepares that data, reading it in, and placing it into the variables that get passed to mplfinance. Thank you. --Daniel |
agri.xlsx
And for the drought index,
And then I do some manipulation to make sure they got same index range
Finally I get the fig which was shown in the previous comment. |
NEVER MIND I see it now. Please ignore this comment. |
OK. I was able to reproduce and I found the problem. I strongly recommend that you do not create your own Figure and Axes. Instead, keep your code simple, as shown in "Fix Number 1" below. To fix the problem, do ONE of the following: Fix Number 1 (preferred)Instead of: fig = mpf.figure(figsize=(16, 7), tight_layout=True,style='default')
ax1 = fig.add_subplot(111)
apds = [mpf.make_addplot(drought.sum(1), ax=ax1, secondary_y=True),]
mpf.plot(c,addplot=apds, ax=ax1,volume=False) Do the following: apds = mpf.make_addplot(drought.sum(1),secondary_y=True)
mpf.plot(c,addplot=apds,volume=False,figsize=(16, 7),tight_layout=True) Here is the result: Fix Number 2 (NOT preferred)Add the line: fig = mpf.figure(figsize=(16, 7), tight_layout=True,style='default')
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
apds = [mpf.make_addplot(drought.sum(1), ax=ax2, secondary_y=True),]
mpf.plot(c,addplot=apds, ax=ax1,volume=False) Here is the result: NOTICE THAT in "Fix Number 2" you can see a vertical line on the left side at the beginning of the |
wow, thanks for your detailed answer. |
New handling of volume exponent; and assorted scratch_pad additions: This PR is primarily to implement a new way to handle the volume exponent; the new way avoids calling `.draw()` which in turn eliminates the bug mentioned in issue #296, and also mentioned/described in a previous email from S.G. ([commit 2c88663](2c88663)) This PR also includes a lot of scratch_pad work for investigations of various issues (#282, #236, #241), and for an mplfinance presentation: including comparison of old and new api's, intraday animation with volumes, generation of animation gifs, etc.
This is the most outstanding help from a package maintainer I have read in a very very long time. |
Is it able to plot a data from pd.DataFrame() (or pd.Series()) object on the axes after mpf.plot()? like plot on to the secondary y axis.
actually the figure i'm going to plot is place a drought index on to corn futures ohlc candlestick plot, somehow it shows up an error with datetime format.
sorry about my grammar, i can post the error message tomorrow and also source data or screenshots.
The text was updated successfully, but these errors were encountered: