1
我想绘制一个蜡烛棒图在python中。这里是我的代码在Python中绘制蜡烛棒
from pandas_datareader import data as pdr
import plotly.plotly as py
import plotly.graph_objs as go
import fix_yahoo_finance as yf
yf.pdr_override()
mcd = pdr.get_data_yahoo("MCD", start="2004-01-01", end="2005-07-31")
mcd_candle = go.Candlestick(x=mcd.index,open=mcd.Open,high=mcd.High,low=mcd.Low,close=mcd.Close)
data = [mcd_candle]
py.iplot(data, filename='Candle Stick')
这是错误我得到
PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, '', we expected it to start with 'https://plot.ly'.
任何想法,我怎么能画K线?
通过实施您的离线方法,我的代码正在运行,但没有看到图形输出。代码运行时没有任何错误。我正在使用Anaconda - Spyder。 Python 3.x –
@DebdiptaMajumdar对不起,你需要在使用spyder时使用'py_offline.plot'而不是'py_offline.iplot',请参考[here](https://stackoverflow.com/questions/35315726/visualize- plotly-charts-in-spyder) –
Naren Murali 非常感谢它的工作 你的天才:) –