Jeremie
Jeremie

Reputation: 435

Pop-up chart with standard python script

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

Answers (1)

Nilesh Ingle
Nilesh Ingle

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

Related Questions