Reputation: 435
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import iplot
import plotly.offline as py_offline
import pandas_datareader as web
from datetime import datetime
py_offline.init_notebook_mode()
df = web.DataReader("aapl", 'morningstar').reset_index()
trace = go.Candlestick(x=df.Date,
open=df.Open,
high=df.High,
low=df.Low,
close=df.Close)
data = [trace]
iplot(data, filename='simple_candlestick')
That code worked pretty well inside a jupyter notebook. Now, I want to execute it inside a standard python script. Once it is executed, I wanted a window to pop-up to see the graph related to that code, but it failed. How could I modify this code so that it works?
Upvotes: 0
Views: 540
Reputation: 1883
Instead of iplot()
in the last line, using py_offline.plot()
should open the plot in a browser window.
py_offline.plot(data, filename='simple_candlestick')
or
py_offline.plot(data)
Upvotes: 1