Skip to content

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

Closed
rman58 opened this issue Jan 21, 2020 · 49 comments
Closed

mpf and subplots #17

rman58 opened this issue Jan 21, 2020 · 49 comments
Assignees
Labels
enhancement New feature or request released code merged into repo AND released to Pypi

Comments

@rman58
Copy link

rman58 commented Jan 21, 2020

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)

@rman58 rman58 added the question Further information is requested label Jan 21, 2020
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jan 23, 2020

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.

mplfinance.plot() does a lot for you automatically. One of the aspects of the code, that allows mplfinance to do so, is that mplfinance.plot() owns the Figure and all Axes. Passing in an Axes object would limit what plot() can do, since it would then not own the Figure and Axes.

Also, passing in an Axes object would effectively make plot() a lower level function, so that in order for plot() to maintain its current capabilities, along with a more limited set of capabilities for the ax=Axes case, the code would become needlessly complex, branching this way and that depending on whether the caller passed in an Axes instance or not.

I am inclined instead to create a new API, similar to plot() but somewhat limited in its capabilities. I imagine something like this:

mpf.axplot(ax, df, type, upcolor, downcolor)

axplot() would do the following:

  • plot either 'ohlc' or 'candle' on the given Axes
  • automatically format the date axis (hours/minutes versus months/years, etc).
  • allow customization of up/down candle and ohlc colors

None of the other features of plot() would be available to axplot() -- no volume, no customization of appearance (other than up/down colors of candles and ohlc), no saving the plot as a file, etc. All of those things can be done by the caller, since the caller has already decided to write lower level code by instantiating and using instances of Figure and Axes.

I am also thinking maybe to restructure the code in such a way that plot() would itself call axplot(). If I can do that, it should make the code easier to maintain -- instead of having to maintain similar code in potentially two different places: both in plot() and in axplot().

@DanielGoldfarb DanielGoldfarb added the enhancement New feature or request label Jan 23, 2020
@schorschie
Copy link

After your explanation I think it would be better to leave the plot() method as is, to keep it's capabilities.
Maybe instead of creating a new api, just return the figure handle of the plot?

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jan 28, 2020

I will consider providing a keyword option to return the Figure. There are potentially problems with this: by maintaining ownership of the Figure and Axes, mpf.plot() is able to do a lot of stuff automatically for the caller. That is part of the philosophy behind mpf.plot() being a "higher level" API compared with the old mpl-finance or the proposed axplot().

So if anything, for now, I will consider an option, maybe noshow=True which means: (1) don't use context manager, (2) don't call plt.show(), and (3) return Figure. It is also almost certain at this point that mpf.axplot() will be written; while it may not be the ideal solution for you, there are definitely others who have expressed an interest in such an API.

Please feel free, everyone, to continue this discussion. My ideal hope for mplfinance is that it can make it easy for people to code 75% to 85% of the use-cases they have (and only slightly more complicated to code the rest). Contributing to these discussions is a great way to help us achieve that goal.

Also, please consider, just as a test/proof of concept, cloning the code and modifying it to return the Figure and then, most importantly, please let me know if that works for you, or if perhaps you come up against another issue that we need to solve. If I know that it easily does for you want you want, that will weigh strongly in favor of me adding the feature to return the Figure object. Thank you.

@verata-veritatis
Copy link

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.

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Feb 2, 2020

@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 mpf.plot(), there are two subplots available: the "main panel" that shows the OHLC bars/candlesticks, and the "lower panel" which can be used to display volume and/or other data. Please make sure you have read through the "additional plot" documentation to see how you can display your RSI indicator on the "lower panel".

As it is now, if you display both volume and an indicator on the lower panel, mpf.plot() will automatically display the indicator on a secondary y-axis.

This feature will be enhanced for the next release of mplfinance as follows: a secondary y-axis will be available for both the main and lower panel, and you will be able to specify for each addplot() call whether you want to plot to be on the primary or secondary y-axis.

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 mpf.axplot() as described above, then you will be able to make as many subplots as you want, and have the freedom to organize them however you want. However it means you have to do a lot of the matplotlib work yourself to structure those plots. This situation won't be much different that the old api (for example, calling candlestick_ohlc()).

We may also make one more subplot avabilable via mpf.plot() (one more than the two that already exist, so a total of three subplots available) and perhaps allow two possible layouts for these subplots. Here are some pictures to clarify:


These two layouts are available now:

  • single main panel
    plot1

  • two panels: main and lower
    plot2


In addition we would make the following layouts available:

  • three panels: main with two below
    plot3

  • three panels: main with one above and one below
    plot3b
    **


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!

@zillionare
Copy link

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.

@DanielGoldfarb
Copy link
Collaborator

@hbaaron please propose how you would want the mpf interface to look/work to do that. Thanks.

@DanielGoldfarb
Copy link
Collaborator

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.

@pkgvrpdm
Copy link

It will be greatly appreciated if many subplots are available in this lib.
One more question can we handle realtime tick by tick data updates in it?

@DanielGoldfarb
Copy link
Collaborator

@pkgvrpdm

... can we handle realtime tick by tick data updates in it?

please check this issue and confirm whether that covers what you are looking for.

@DanielGoldfarb
Copy link
Collaborator

Here is my current thinking regarding subplots: I did some experimenting with creating a Figure and subplots outside of mpf.plot() and passing the subplot Axes objects into mpf.plot(). The problem with that was that sometimes mpf.plot() applied its style and sometimes it didn't. It seemed that the style was not applied to the first subplot but was (at least partially) to later subplots.

The issue keeps coming back to the idea that that mpf.plot() does a lot for you, allowing you to write a lot less code than the old API, but it does so by taking advantage of the ownership it has over the Figure and Subplots.

So one possibility is to provide a "stripped down" version of mpf.plot(), what I called mpf.axplot() above, that would leave subplot creation, styling, some formatting, and a bunch of other things up to the caller, and would just do the basic OHLC Bars or Candlestick plotting for you. But it seems to me that's about the same as just calling the original APIs (for example, plot_day_summary_ohlc() and candlestick_ohlc()) so I don't think it's a good idea to just recreate that API.


Now I am thinking this: I could provide something like

fig = mpf.make_figure() 

and

axes1 = mpf.make_subplot(figure=fig,<subplot_configuration1>)
axes2 = mpf.make_subplot(figure=fig,<subplot_configuration2>)
axes3 = mpf.make_subplot(figure=fig,<subplot_configuration3>)
axes4 = mpf.make_subplot(figure=fig,<subplot_configuration4>)

and these functions would return Figure and Axes as objects that are specific to, and owned by, mplfinance.

Then the caller can pass these objects into

make_addplot(ax=subplotN)

and

mpf.plot(ax=subplot1,volume=subplot2,addplot=apd).

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 mplfinance subplot interface to look and feel let me know. If no one has any preferences then I will just do something like what I have outlined here (assuming the experiments work out and I don't run into any snags).

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.

@pkgvrpdm
Copy link

@pkgvrpdm

... can we handle realtime tick by tick data updates in it?

please check this issue and confirm whether that covers what you are looking for.

It seems to cover the issue of realtime plotting, thanks very much, I will try it latter.

@markthebault
Copy link

Here is my current thinking regarding subplots: I did some experimenting with creating a Figure and subplots outside of mpf.plot() and passing the subplot Axes objects into mpf.plot(). The problem with that was that sometimes mpf.plot() applied its style and sometimes it didn't. It seemed that the style was not applied to the first subplot but was (at least partially) to later subplots.

The issue keeps coming back to the idea that that mpf.plot() does a lot for you, allowing you to write a lot less code than the old API, but it does so by taking advantage of the ownership it has over the Figure and Subplots.

So one possibility is to provide a "stripped down" version of mpf.plot(), what I called mpf.axplot() above, that would leave subplot creation, styling, some formatting, and a bunch of other things up to the caller, and would just do the basic OHLC Bars or Candlestick plotting for you. But it seems to me that's about the same as just calling the original APIs (for example, plot_day_summary_ohlc() and candlestick_ohlc()) so I don't think it's a good idea to just recreate that API.

Now I am thinking this: I could provide something like

fig = mpf.make_figure() 

and

axes1 = mpf.make_subplot(figure=fig,<subplot_configuration1>)
axes2 = mpf.make_subplot(figure=fig,<subplot_configuration2>)
axes3 = mpf.make_subplot(figure=fig,<subplot_configuration3>)
axes4 = mpf.make_subplot(figure=fig,<subplot_configuration4>)

and these functions would return Figure and Axes as objects that are specific to, and owned by, mplfinance.

Then the caller can pass these objects into

make_addplot(ax=subplotN)

and

mpf.plot(ax=subplot1,volume=subplot2,addplot=apd).

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 mplfinance subplot interface to look and feel let me know. If no one has any preferences then I will just do something like what I have outlined here (assuming the experiments work out and I don't run into any snags).

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.

Thanks for the awesome job, I think returning a figure would also a good improvement.

@MikeAMCloud
Copy link

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.

@paos
Copy link

paos commented Mar 14, 2020

+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 :-)

@DanielGoldfarb DanielGoldfarb self-assigned this Mar 16, 2020
@DanielGoldfarb DanielGoldfarb removed the question Further information is requested label Mar 22, 2020
@thatsblatzphemy
Copy link

thatsblatzphemy commented Mar 26, 2020

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.

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!!!

@DanielGoldfarb
Copy link
Collaborator

@thatsblatzphemy
Thanks for your input. Definitely appreciated! And it appears to me (based on your suggestions and how clearly you've expressed them) that having "only learned what a command prompt was a month or so ago" is not a factor in this dicussion.

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:

At present, via mpf.plot(), there are two subplots available: the "main panel" that shows the OHLC bars/candlesticks, and the "lower panel" which can be used to display volume and/or other data. Please make sure you have read through the "additional plot" documentation to see how you can display your RSI indicator on the "lower panel".

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?

  • If you can please actually use make_addplot() to plot RSI, and then answer the above questions, that would be very helpful.

Now, to clear up a couple of the other misconceptions in your comments:

  1. A regular matplotlib style (rcparams) does not allow you to control the candlestick and ohlc bar colors. That is the main purpose of an mpf_style. It is simply a combination of the "market colors" and matplotlib styles (rcparams). Nothing more really. And you can still do everything you want to with rcparams.

  2. If you want full and complete matplotlib control over everything (and the work associated with that) then you are free to use the old API for which you can find examples here, and documentation here.

  3. The ability to pass in your own Figure and Axes is definitely coming. That's why I'm keeping this issue open, and have labeled it "enhancement." I am also fairly certain that I won't actually need to do as I outlined above (having mplfinance create and maintain ownership of the Figure and Axes), but I have a few more tests to run to make sure it does not break any of the advantages that mplfinance provides over the old API.

  4. If you do have experience working with the old API, and with the new API, then you know how much extra work the old API required. For someone well versed and experienced in matplotlib, that's not a big deal. That's why the old API is still available in this package. But a very large number of users are less interested in becoming matplotlib experts and more interested in focusing on the visual analysis of their data. The new API allows them to do that.

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

@kono10
Copy link

kono10 commented Mar 27, 2020

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!

@DanielGoldfarb
Copy link
Collaborator

Correct, returnfig has been implemented. But it will accomplish only a small part of what is discussed here. (try it and see). Nonetheless, it will help.

I am keeping this current issue open in expectation of implementing the ability to create your own Figures and Axes and pass them into mpf.plot().

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 returnfig or any of the other "merged and awaiting release" items, you can install it as follows:

  1. git clone [email protected]:matplotlib/mplfinance.git
  2. cd into the main mplfinance directory of the repository (the one that contains setup.py)
  3. pip install . <enter> # Notice the dot '.' in pip install .

HTH

@maop72
Copy link

maop72 commented Apr 11, 2020

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.

@thatsblatzphemy
Copy link

thatsblatzphemy commented Apr 12, 2020 via email

@Faisal-gr
Copy link

Hi Daniel, first of all I wanted to thank you for your great effort.
I'm curious, can the 'lower' part of the plot include a bar chart? I know logically it should because the volume is a bar chart as well. I'm fairly new at using python so my logic could be flawed.
I read the "additional plot" documentation and I couldn't find any mention of the plot types it accepts (and how to do it).
The reason I am asking: I wanted to plot a MACD with its histogram in the lower section by turning the volume bars off, while keeping the stock price in the main.
I managed to plot the MACD, but not its histogram because I couldn't tell how to make the lower section include a bar chart.

@DanielGoldfarb
Copy link
Collaborator

I read the "additional plot" documentation and I couldn't find any mention of the plot types it accepts (and how to do it).

@Faisal-gr ... You are correct in thinking that mpf.make_addplot() should be the way to do it, however presently make_addplot() assumes a line plot, or if scatter=True then a scatter plot.

In theory we could add a plot_type=[line|scatter|bar] to mpf.make_addplot(). If you want, take a look at the code and see how you might do that. Aside from allowing make_addplot() able to accept plot_type kwarg, the actually implementation of the bar chart would be within the "addplot" section of the mpf.plot() in file plotting.py Let me know if you are interested in getting involved and I can advise. Otherwise I can put it on the list of things to do and it will get done eventually.

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.

@Faisal-gr
Copy link

@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
Copy link

krychu commented May 26, 2020

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!

@DanielGoldfarb
Copy link
Collaborator

@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

@krychu
Copy link

krychu commented May 27, 2020

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 .plot([ds1, ds2, ds3], ...). ohlc and volume charts would be created just like any other chart with make_addplot. This way you could have multiple ohlc charts in one figure. Just a thought.

@DanielGoldfarb
Copy link
Collaborator

@krychu

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 addplot. And there are differences for the renko and point and figure charts as well.

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

@krychu
Copy link

krychu commented May 29, 2020

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):

  • filled bands
  • drawing vertical lines spanning all stacked charts (probably hard to implement)
  • drawing arbitrary lines, and filled rectangles (without left and right borders)

Thanks again and good luck!

@DanielGoldfarb
Copy link
Collaborator

@krychu

  • filled bands is now possible, using the fill_between kwarg (presently only supported for the "main" panel)
  • vertical lines are available, but also presently only supported for the main panel. probably not too difficult to have a vertical line drawn for all panels, since as they are now they all share the same x-axis.
  • arbitrary lines also available now, but again only for main panel presently.
  • lines documentation here
  • not sure what you are getting at with filled rectangles. what are you trying to accomplish from a financial visualization perspective?

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.

@DanielGoldfarb DanielGoldfarb added released code merged into repo AND released to Pypi and removed in progress labels Jun 8, 2020
@joeatbayes
Copy link

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.

@DanielGoldfarb
Copy link
Collaborator

@joeatbayes
Joe, by the way, not sure if you noticed, but even though the old package is deprecated, the old api is still available within the new mplfinance package. See here: https://github.com./matplotlib/mplfinance#oldapi HTH. --Daniel

@usimjo
Copy link

usimjo commented Mar 1, 2021

How can I put a few marker on candle chart like as Moving Average
marker position is random position which I want to mark it.

@DanielGoldfarb
Copy link
Collaborator

@usimjo
Please take 15 minutes of your time to carefully read these tutorials:

Please also see the list of tutorials here:

Let me know if you have any other questions after that.
All the best. --Daniel

@jake1271
Copy link

jake1271 commented Aug 7, 2021

Hi @DanielGoldfarb ,
Thanks for the great work you do, mplfinance is awesome!
I was wondering if it was possible to add panels to subplots? Basically I'm looking to create a grid of charts that each have one or two additional panels, to show custom indicators like Stochastic or MACD? I did see your "How to use your own matplotlib Figure and Axes in mplfinance" where you show 3 charts side by side with a volume panel below but those lower panels are quite a bit separated from the main panel with duplicated x-axis labels.

Here's an example of what I'm describing:
GridCharts

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!

@mablue
Copy link

mablue commented Oct 19, 2021

Hi @DanielGoldfarb , Thanks for the great work you do, mplfinance is awesome! I was wondering if it was possible to add panels to subplots? Basically I'm looking to create a grid of charts that each have one or two additional panels, to show custom indicators like Stochastic or MACD? I did see your "How to use your own matplotlib Figure and Axes in mplfinance" where you show 3 charts side by side with a volume panel below but those lower panels are quite a bit separated from the main panel with duplicated x-axis labels.

Here's an example of what I'm describing: GridCharts

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?!

@DanielGoldfarb
Copy link
Collaborator

@mablue see also https://github.com./matplotlib/mplfinance/blob/master/examples/external_axes.ipynb

@hellovikas
Copy link

Please anyone can tell ,There is any simpler way to change volume panel from bar type to line or something else

@DanielGoldfarb
Copy link
Collaborator

@hellovikas
The simplest way to make volume a line-plot (or anything other than a bar plot) is to use mpf.make_addplot() to plot the volume. You will, of course in that case, not set the volume kwarg at all.

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.

@hellovikas
Copy link

@hellovikas The simplest way to make volume a line-plot (or anything other than a bar plot) is to use mpf.make_addplot() to plot the volume. You will, of course in that case, not set the volume kwarg at all.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests