mplfinance:不使用“ohlc”绘制一条线数据框?
我想在不使用“默认 ohlc 数据”的情况下绘制一条线。 在本例中,我使用 Github 中的数据。
我该怎么做?
import pandas as pd
import mplfinance as mpf
import matplotlib.animation as animation
import numpy as np
path_ = 'C:\Mypath'
intraday = pd.read_csv(path_+'SP500_NOV2019_IDay.csv',index_col=0,parse_dates=True)
intraday.index.name = 'Date'
# mpf.plot(intraday,type='line') #ohlc DataFrame.. ok
int_Low = intraday.loc[:,'Low'] #non ohlc DataFrame
mpf.plot(data=int_Low,type='line') #doesn't work
I would like to plot a line without using a "default ohlc data".
In this case, I'm using the data in the Github.
How can I do this?
import pandas as pd
import mplfinance as mpf
import matplotlib.animation as animation
import numpy as np
path_ = 'C:\Mypath'
intraday = pd.read_csv(path_+'SP500_NOV2019_IDay.csv',index_col=0,parse_dates=True)
intraday.index.name = 'Date'
# mpf.plot(intraday,type='line') #ohlc DataFrame.. ok
int_Low = intraday.loc[:,'Low'] #non ohlc DataFrame
mpf.plot(data=int_Low,type='line') #doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

不幸的是,正如 mplfinance 现在一样,在绘制
type='line'
时,mpf.plot(data,type='line')
默认情况下将使用 'Close ' 柱子。一种可能的解决方法是将“低”数据放入“关闭”列中。
另一个解决方案可能是增强 mplfinance 以接受名为
use_column
的 kwarg。然后,例如,可以简单地写:此增强功能相对容易实现(只需几行代码)。如果您有兴趣为 mplfinance 做出贡献,请在下面的评论中告诉我。完全披露:我是 mplfinance 的维护者。
Unfortunately, as mplfinance is now, when plotting
type='line'
thenmpf.plot(data,type='line')
will, by default, use the 'Close' column.One possible work-around would be to put your 'Low' data into the 'Close' column.
Another solution might be to enhance mplfinance to accept a kwarg called
use_column
. Then, for example, one could simply write:This enhancement is relatively easy to implement (just a few lines of code). Please let me know, in a comment below, if you are interested in contributing to mplfinance. Full disclosure: I am the maintainer of mplfinance.