Skip to content
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

ylim kwarg for volume axes #371

Open
ghost355 opened this issue Apr 5, 2021 · 4 comments
Open

ylim kwarg for volume axes #371

ghost355 opened this issue Apr 5, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@ghost355
Copy link

ghost355 commented Apr 5, 2021

Hi, how to set ylim for volume panel if I use code like this:
mpf.plot(df, volume=ax2)
I tried ax2.set_ylim(0,0.5) but it didn't work
I think mpf.plot use its own setting

@ghost355 ghost355 added the question Further information is requested label Apr 5, 2021
@ghost355
Copy link
Author

ghost355 commented Apr 5, 2021

Suppose I found something )))
I need add
ax2.set_ylim(0,0.5) AFTER mpf.plot()

@DanielGoldfarb
Copy link
Collaborator

Pavel,

Yes, mpf.plot() has special treatment for volume limits: Since volumes tend to be large numbers, mpf.plot() will make the the lower limit approximately 0.3 times the smallest volume (rather than zero as would otherwise normally be the case).

I thought I had implemented a volume_ylim kwarg, but I guess I only thought about it and didn't actually do it ;-)

There are a couple of workarounds (until volume_ylim is implemented)

  • your suggestion of calling Axes.set_ylim() after calling mpf.plot(). This works for both external axes mode and for returnfig=True mode.
  • use make_addplot() to plot something (even a single data point) on the same axes as the volume, and pass ylim kwarg into make_addplot() (you may also have to pass in secondary_y=False to ensure the ylim gets applied to the correct primary volume axis).

Would you like to implement a volume_ylim kwarg and contribute to mplfinance? I can provide guidance if desired.
Thanks. --Daniel

@ghost355
Copy link
Author

ghost355 commented Apr 5, 2021

Thanks Daniel
The way with ax.set_ylim(bottom,top) is very comfortable, I guess and gives very flexible handling.
I am afraid, I have no needing skill to contribute any thing to mplfinance )))

@DanielGoldfarb
Copy link
Collaborator

OK. Thanks. I'm going to leave this issue open as a reminder to me to add a volume_ylim kwarg.

@DanielGoldfarb DanielGoldfarb changed the title Managing ylim for volume with external axis ylim kwarg for volume axes Apr 5, 2021
@DanielGoldfarb DanielGoldfarb added enhancement New feature or request and removed question Further information is requested labels Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants