-
Notifications
You must be signed in to change notification settings - Fork 658
mpf and subplots #17
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
This is the second request I've gotten for something like this, so will probably do something about it. There are some issues though. I'll describe here what I am thinking so that people can comment.
Also, passing in an Axes object would effectively make I am inclined instead to create a new API, similar to
None of the other features of I am also thinking maybe to restructure the code in such a way that |
After your explanation I think it would be better to leave the |
I will consider providing a keyword option to return the So if anything, for now, I will consider an option, maybe Please feel free, everyone, to continue this discussion. My ideal hope for Also, please consider, just as a test/proof of concept, cloning the code and modifying it to return the |
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 |
@verata-veritatis ... I just want to clarify a few things on my end, and then ask for some clarification as to what you want to see. At present, via As it is now, if you display both volume and an indicator on the lower panel, This feature will be enhanced for the next release of Now the question is, after reading the "additional plot" documentation are you able to display your RSI indicator? Is there something else you need (if so, what)? Do you have a specific need for more subplots(), and if so for what? Here is my current thinking on additional subplots: If we implement We may also make one more subplot avabilable via These two layouts are available now: In addition we would make the following layouts available: Please let me know if the two panel case (the one that exist now: see "additional plot" documentation) is adequate for what you want to do. If not, please explain clearly why it's not adequate. Also, if the existing two panel case will not work, indicate whether or not you think the above proposal (of a few different layouts) or something similar would work. Thank you! |
Hi Daniel, Thanks for the effort. I personally would like to see if mpf have the ability to draw subplots. The reason: I need to draw candlestick for at least two timeframe( day and 30min), and a corresponding index candlestick. |
@hbaaron please propose how you would want the mpf interface to look/work to do that. Thanks. |
double y-axis is now released. See the "additional plot" documentation here. I am currently experimenting with a couple different ways of implementing subplots to see which is going to work the best. |
It will be greatly appreciated if many subplots are available in this lib. |
please check this issue and confirm whether that covers what you are looking for. |
Here is my current thinking regarding subplots: I did some experimenting with creating a Figure and subplots outside of The issue keeps coming back to the idea that that So one possibility is to provide a "stripped down" version of Now I am thinking this: I could provide something like
and
and these functions would return Figure and Axes as objects that are specific to, and owned by, Then the caller can pass these objects into
and
I plan to do some experimenting with this idea and see how it works out. I am in the middle of some other projects so it may take me some time. In the meantime ... I would be very interest to hear from others what they think of this idea/this proposed interface for subplots. Also, if any of you have ideas or preferences for how you want the Thank you all, and please continue to contribute your ideas and suggestions. And, of course, if any one wants to contribute coding skills that is also welcome. |
It seems to cover the issue of realtime plotting, thanks very much, I will try it latter. |
Thanks for the awesome job, I think returning a figure would also a good improvement. |
I have found that mplfinance to be a great benefit in it's simplication and reduction of the work required. That being said an ability to extend beyond the current limit of two subplots would be greatly appreciated. If the code is extended to add a third (or more) subplot, with mplfinance retaining it's control and feature set, that would seem to be a superior solution. The above solution works, as well as, the previous suggestion to add a "third" subplot window. |
+1 to be able to have access to the figure and axes outside of mpf, it is really important if you want to freely use matplotlib with the graphs (and who wouldn't want that?). Thank you :-) |
Hello Daniel. Thank you for all the hard work. I hope you'll accept my input with a grain of salt. I only learned what a command prompt was a month or so ago. I have came a long way. Only to finally get hung up for multiple days on this exact concept from OP I quoted here. I cannot plot an RSI in mplfinance. I am developing an algo, and as OP suggested... highly detrimental to the cause. IMO, the mpf function simply cannot control the figure. I tried multiple things ... like attempting to call the mpf function individually from within a ax2 or the like subplot, but to no avail. I keep envisioning calling an instance of the mpf function individually within an axes subplot call is the solution. But of course, I have absolutely no idea what I'm talking about. The only real necessity of this program IMO is to leverage the customizations of matplotlib itself. We really just need the candle visualizations. And infact, the only reason I kept trying this way instead of using old flavour was because I really just wanted to be able change the borders and wicks color of my candle bodies. So your mpf function IMO severely limits the real world application of this package. I think you should ditch it entirely. Leave the customization upto the individual to control themselves with the RCPARAMS sheet, and matplotlib styles. Ditch the MPLFinance styles. Irrelevent and un needed. This is the way. Thank you so much!!! |
@thatsblatzphemy That said, you appear to have some misconceptions about mplfinance and what you can presently do with it: You absolutely can plot RSI as the package exists now. Let me quote from my reply, to the comment from which you quoted "I think the ability to add a subplot ...". And please note that my reply asks a couple of questions at the end, for which I still have as yet to receive an answer:
Now, to clear up a couple of the other misconceptions in your comments:
Again, it would be greatly appreciated if you could take the time to use the addplot functionality for RSI, or whatever other technical studies you would like to add, and then send me feedback. All the best. Stay safe and healthy. --Daniel |
Looks like returnfig has been implemented as an argument in the master branch of this repo. That should accomplish what has been discussed here. Any idea when you will release it to PyPi? Thank you! |
Correct, I am keeping this current issue open in expectation of implementing the ability to create your own Figures and Axes and pass them into Regarding the next release: Issue 67 is being used to track the next Pypi release. There will be 6 items included in that release, and as you can see from the list there, three items are "merged and awaiting release" and three are "in progress". I am hoping the release will be ready by the end of next week. In the meantime, if you would like to play with
HTH |
ok, thank you, I have read this thread again and I see that my question is already answerd: there will be a way to manage several axes, what Daniel calls "external axes". But with a new low level API, because maintaining old API would be a not reasonable effort. Please apologize my post, it was not needed. Even though I think that would be a good idea that main documentation warns about this : there will be a new low level api, if you need access to axes, use old one meanwhile. Again, thank you all. |
Yup you got it. All under control. Just gotta wait to open our presents
like good patient children until then! Cheers!
…On Sat, Apr 11, 2020 at 5:34 AM Miguel Ortuño ***@***.***> wrote:
ok, thank you, I have read this thread again and I see that my question is
already answerd: there will be a way to manage several axes, what Daniel
calls "external axes". But with a new low level API, because maintaining
old API would be a not reasonable effort.
Please apologize my post, it was not needed. Again, thank you all.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com./notifications/unsubscribe-auth/AO6REWCEUAFNVANLFJXCR73RMBIUXANCNFSM4KJYKJKA>
.
|
Hi Daniel, first of all I wanted to thank you for your great effort. |
@Faisal-gr ... You are correct in thinking that In theory we could add a A kludge/work-around, in the meantime, might be to pass your MACD histogram in as a column of your dataframe named 'Volume' and set Volume=True. |
@DanielGoldfarb Thank you very much for your timely response. I appreciate the work-around suggestion; I will certainly try to use that and see how it pans out until a future update is rolled out. Regarding the code, my experience is very limited as I'm only 1 week into coding although I came a long way given the short time frame, but I will definitely take a look at it. If anything, it will give me an appreciation of the work done 'behind the scenes'. Thanks again and I appreciate you considering it in future updates. |
@krychu , I agree with you completely. Part 1 is almost done. You can see a tutorial for it here in my fork which I expect to merge into matplotlib/mplfiance master within a day or two. (Just finishing up some additional documentation and testing). All the best. --Daniel |
Just read through it, this is fantastic @DanielGoldfarb. Thank you. Another thought that came to mind: is the distinction between main and additional plots necessary? An option would be to have |
I agree. And there is a plan to allow any chart type on any panel; I want it to to seem that simple to the user. But under the hood it will require a significant restructuring of the code, so I am taking time to do it step-by-step to avoid breaking any existing functionality. The need to restructure the code is partly historical, but mostly because, what is not always apparent to the user is that, mplfinance does a lot of stuff for you automatically to try to make things easier. This requires handling different plot types somewhat differently from each other. For example, handling up/down colors, styles, etc. There is also an algorithm (improved with the next version) that adjusts candle widths and wicks to look good over a variety of data patterns. (Candle widths that look good with one data set may not look good with another. The old mplfinance required the user to make adjustments like that themselves.) Even plotting volume is not the same as plotting a simple bar chart with All this is to say it can be done, but it will take some time. One of the "disadvantages" of abstracting away all the work, is that it can become difficult to appreciate just how much is being done to achieve that abstraction (unless, of course, you've used the previous package where you had to do all that work yourself). Again, thanks for your input. And if you'd like to share some of the plots you've made that would be very much appreciated. It's nice to see some of the creative things people are doing with this package. All the best. --Daniel |
Thanks @DanielGoldfarb I can imagine this being a major restructure as it changes the fundamental model of the API. But I'm glad it's on your roadmap. As a user I fully appreciate the difficulty of hiding all the complexities and know it requires a lot of work. I also believe financial domain is where it will work well because there is a strong use-case and understanding of what the final chart should be. Once I have something reasonable I'll send your way. Sorry for diverging in this issue but wanted to throw few things that would be useful (perhaps they are already supported in which case apologies):
Thanks again and good luck! |
I am going to close this issue. However we can continue the discussion here on the closed issue to sort out exactly what you are looking for. I am only closing it because I want each issue to represent one feature request or one bug. I have implemented a limited form of subplots, as described here as the "Panels Method". I am planning to implement a more general form of subplots as described here as "The Matplotlib Method". I will open a separate Issue to track that feature request. Ultimately I would love to get mplfinance to a point where it can, in a relatively easy-to-do way, make a plot similar to this in all its glory (including all of the labels, colors, and annotations) but that will take some time ... less time if others contribute, but time none-the-less. |
My existing plots directly use matPlotLib I want to add candle sticks to those graphs not have the candle stick take over. In the old api at mpl_finance it worked great I just passed in the axis of my existing work. You really should support the old strategy. I will just use the deprecated version until you do. |
@joeatbayes |
How can I put a few marker on candle chart like as Moving Average |
@usimjo
Please also see the list of tutorials here: Let me know if you have any other questions after that. |
Hi @DanielGoldfarb , Here's an example of what I'm describing: I've look around but can only find references to single charts which you already covered quite well in "Adding plots to the basic mplfinance plot()" I think grid of charts would be quite invaluable for displaying multiple time frames as well as overviews of related stocks in sectors. Thanks again! |
I really want to know how you do that?! |
Please anyone can tell ,There is any simpler way to change volume panel from bar type to line or something else |
@hellovikas I suggest you read through these two tutorials first: I strongly recommend that you do not use the external axes method this is being discussed in this issue above. If you have any questions, after reading through the above two tutorials, then let me know. |
Thnx Sir i have achieved by make_addplot plot rather than using volume to true |
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)
The text was updated successfully, but these errors were encountered: