import plotly

plotly.tools.set_credentials_file(username='atmamani',
                                  api_key='xxx')

"""
Explanation: <center><h1>Interactive plots with Plotly and Cufflinks</h1></center>
<img src=https://s3-us-west-1.amazonaws.com/plotly-tutorials/plotly-marketing-pages/images/new-branding/logo/images/plotly-logo-01-stripe%402x.png height="100" width="400">
Plotly is a JS based plotting library with Python bindings (similar to bokeh). Plotly also has a portal online where users can upload their charts for public use.
Installation
pip instal plotly
login
import plotly
plotly.tools.set_credentials_file(username='', api_key='')
create your key here: https://plot.ly/settings/api
Online and Offline plotting
Plotly allows you to plot both 
 - online - plot data is set online to your account.
   - plot() - returns a unique url and opens it new tab
   - iplot() - when using notebook to embed the plot
 - offline - explicit call
   - offline.plot - creates a new html output page
   - offline.iplot - interactive while in a notebook
End of explanation
"""


import plotly.plotly as py
from plotly.graph_objs import *

trace0 = Scatter(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = Scatter(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])

py.plot(data, filename = 'basic-line2')

"""
Explanation: Online plotting
plot command
End of explanation
"""


import plotly.plotly as py
from plotly.graph_objs import *

trace0 = Scatter(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = Scatter(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])

py.iplot(data, filename = 'basic-line')

"""
Explanation: iplot command
End of explanation
"""


import plotly
from plotly.graph_objs import Scatter, Layout

plotly.offline.plot({
    "data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
    "layout": Layout(title="hello world")
})

"""
Explanation: Offline plotting
plot command
End of explanation
"""


import plotly
from plotly.graph_objs import Scatter, Layout

# init code
plotly.offline.init_notebook_mode(connected=True)

plotly.offline.iplot({
    "data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
    "layout": Layout(title="hello world")
})

"""
Explanation: iplot command
You need to set initialization code, similar to matplotlib
End of explanation
"""


