简体   繁体   English

有没有办法在图的烛台下方/下方设置 vlines? (财务)

[英]Is there a way to set the vlines below/under the candlesticks on plot? (mplfinance)

I am currently using vlines to shadow in afterhours/premarket trading.我目前正在使用 vlines 在盘后/盘前交易中进行跟踪。 However, the candlesticks are under the vlines and as such they become harder to read if I increase the alpha kwarg.但是,烛台位于 vlines 下方,因此如果我增加 alpha kwarg,它们会变得更难阅读。 Is there a way to put the vlines under the candlesticks as opposed to above them?有没有办法将 vlines 放在烛台下方而不是上方? Using the mplfinance lib.使用 mplfinance 库。

数字

PS: the vlines are also ever so slighly off the top of the plot, is there a way for them to go all the way up to the top edge? PS:vline 也曾经如此轻微地脱离情节的顶部,有没有办法让它们一直走到顶部边缘?

fig, axlist = mpf.plot(df,
                           type='candle',
                           volume=True,
                           ylabel='',
                           ylabel_lower='\n<thousands>',
                           returnfig=True,
                           style=style,
                           figratio=(21, 9),
                           warn_too_much_data=970,
                           addplot=vwap,
                           hlines=dict(hlines=previousCloseLine(), colors='white', linestyle='dashed'),
                           vlines=dict(vlines=df.between_time('16:00', '09:30').index.tolist(), colors='#323538', linewidths=1, alpha=0.5),
                           datetime_format='%H:%M',
                           tight_layout=True
                           )

Regarding your first question (vlines below candlesticks), sounds like you are asking about zorder .关于您的第一个问题(烛台下方的 vlines),听起来您在询问zorder If so, mplfinance presently does not give you direct access to zorder.如果是这样,mplfinance 目前不允许您直接访问 zorder。 There is an enhancement request for it that unfortunely got pushed onto the back-burner in favor of some other enhancements.不幸的是,有一个增强请求被推到了次要位置,以支持其他一些增强。 There may be a work-around using returnfig=True but I'm not sure yet if that can work (would have to run some experiments to see if zorder can be modified this way).使用returnfig=True可能有一种解决方法,但我不确定这是否可行(必须进行一些实验以查看是否可以通过这种方式修改 zorder)。

In the meantime , given what you are trying to do (shade an area of the plot) you might try mplfinance's fill_between feature .同时,考虑到您正在尝试做的事情(阴影区域),您可以尝试 mplfinance 的fill_between功能 Don't know if that will have the same zorder issue or not, but it is worth a try.不知道这是否会有相同的 zorder 问题,但值得一试。


Regarding your second question (about vlines not quite reaching the top of the plot), not sure what's causing that, or whether it is inherent to mplfinance and/or to matplotlib, possibly only in response to certain data.关于你的第二个问题(关于 vlines 没有完全到达情节的顶部),不确定是什么原因造成的,或者它是否是 mplfinance 和/或 matplotlib 所固有的,可能只是为了响应某些数据。

One possible workaround, in the meantime, may be to set the ylim=(ymin,ymax) kwarg to set ymin and ymax manually (instead of letting mplfinance determine them automatically).同时,一种可能的解决方法可能是将ylim=(ymin,ymax) kwarg 设置为手动设置 ymin 和 ymax(而不是让 mplfinance 自动确定它们)。 It may be worth adding an issue to the mplfinance page, including all the data and code necessary to reproduce the issue. 将问题添加到 mplfinance 页面可能值得,包括重现问题所需的所有数据和代码。 It doesn't seem to me that vlines should stop short of the top like that.在我看来,vlines 似乎不应该像那样停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM