ylim kwarg for volume axes
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
Suppose I found something )))
I need add
ax2.set_ylim(0,0.5) AFTER mpf.plot()
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 callingmpf.plot(). This works for both external axes mode and forreturnfig=Truemode. - use
make_addplot()to plot something (even a single data point) on the same axes as the volume, and passylimkwarg intomake_addplot()(you may also have to pass insecondary_y=Falseto ensure theylimgets 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
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 )))
OK. Thanks. I'm going to leave this issue open as a reminder to me to add a volume_ylim kwarg.