Giter VIP home page Giter VIP logo

Comments (8)

DanielGoldfarb avatar DanielGoldfarb commented on May 28, 2024

I suggest, do not do subplots. Do only panels.

Officially there can only be one "main" plot. However you can make a "second" main plot by passing type='candle' to one of your make_addplot() calls.

from mplfinance.

archerhu77 avatar archerhu77 commented on May 28, 2024

I suggest, do not do subplots. Do only panels.

Officially there can only be one "main" plot. However you can make a "second" main plot by passing type='candle' to one of your make_addplot() calls.

But if only one main plot with three panel, that will make all three panel share x-axis whith main plot. And that's not I want.
I want to show a plot with it's panel and other plot with it's panel, they are daily klines and 60min klines, and they have different x-axis.

I found a way to do that what generate two image and merge together, but I think it's not a best way(or offical way) to do that. And it is not any clue in offical document told me that couldn't put subplot and panel together.

from mplfinance.

archerhu77 avatar archerhu77 commented on May 28, 2024

I found a way to do similar thing in following code:

fig = mpf.figure(figsize=(8,6))
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
av1 = fig.add_subplot(2,2,3)
av2 = fig.add_subplot(2,2,4)

mpf.plot(df1,type='candle',ax=ax1, mav=(5),axtitle='stock1')
mpf.plot(df2,type='candle',ax=ax2, mav=(5),axtitle='stock2')
av1.plot(df1.index,df1['rsi6'])
av2.plot(df2.index,df2['rsi6'])
mpf.show()

It's make a 2x2 subplots, use mpf draw candlestick, use matplotlib.pyplot to draw rsi6.
But there is some problem like: ax1 and av1 couldn't share x-axis, the result seems amateurish, etc.
This is not a satisfactory solution.

from mplfinance.

DanielGoldfarb avatar DanielGoldfarb commented on May 28, 2024

The number of panels is entirely up to you ... you decide and code it accordingly.

Take a look, for example, at cell In [24] near the bottom of https://github.com/matplotlib/mplfinance/blob/master/examples/addplot.ipynb

from mplfinance.

archerhu77 avatar archerhu77 commented on May 28, 2024

The number of panels is entirely up to you ... you decide and code it accordingly.

Take a look, for example, at cell In [24] near the bottom of https://github.com/matplotlib/mplfinance/blob/master/examples/addplot.ipynb

Thanks for your reply. I try to check the code you said. Yes, it can set serval panel in a plot, but they will share same x-axis. That's not the situation what I said.

I want the result is: create a one column four row plot. the first row is candlestick 1(which is daily k-lines), the second row is rsi6 for the first row, they will share x-axis. And the third row is candlestick 2(which is 60min k-lines, so it's will use a different x-axis), the fourth row is rsi6 for the third row, the third and fourth row will share x-axis.

from mplfinance.

DanielGoldfarb avatar DanielGoldfarb commented on May 28, 2024

I'm sorry, I didn't read carefully enough. I didn't realize you wanted two different x-axes. Yes, the way mplfinance is written, panels will always share x-axes, so you will have to use external axes mode. I will go back and read more carefully and see if I can find a better solution for you.

from mplfinance.

archerhu77 avatar archerhu77 commented on May 28, 2024

I'm sorry, I didn't read carefully enough. I didn't realize you wanted two different x-axes. Yes, the way mplfinance is written, panels will always share x-axes, so you will have to use external axes mode. I will go back and read more carefully and see if I can find a better solution for you.

Thank you very much.

I tried lots of solution but all failed. It seems your solution posted at other issue what generate two image and merge together is the only way to do that.(#318 (comment))

from mplfinance.

archerhu77 avatar archerhu77 commented on May 28, 2024

It seems to generate two image of candlestick and combine to one in fig is the only way to solve it. But it's clearly it will bring some shortcomings(for example it's hard to add mouse cross because it's not a candlestick but a image).

I will close this issue, thanks @DanielGoldfarb

from mplfinance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.