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 非常感謝它的工作 你的天才:) –