In [1]:
import plotly.plotly as py
import cufflinks as cf
import pandas as pd
import numpy as np
import plotly.graph_objs as go
%matplotlib inline
In [2]:
df = cf.datagen.lines()
df.head()
Out[2]:
Plotting through the plotly interface
In [3]:
py.iplot([{
'x': df.index,
'y': df[col],
'name': col
} for col in df.columns], filename='simple-line')
Out[3]:
Alternatively, use cufflinks to access iplot through pandas
In [4]:
p = df.iplot(kind='scatter', filename='simple-line', asFigure=True)
In [5]:
print(p.to_string())
In [6]:
dir(p)
Out[6]:
In [7]:
py.iplot(p)
Out[7]:
In [ ]:
In [8]:
for l in p.data:
pass
# l.line.color = (l.line.color[0] - 0.2, l.line.color[1]-0.2, l.line.color[2]-2)
# l['line']['style'] = 'longdash'
# l['line']['color'] = (0.5,0.5,0.5)
l['line']['color'] = 'red'
l['line']['dash'] = 'longdash'
# print(l['line']['color'])
p.data[0].mode = 'lines+markers'
py.iplot(p)
Out[8]:
In [9]:
p = py.iplot([{
'x': df.index,
'y': df[col],
'name': col
} for col in df.columns], filename='simple-line')
In [10]:
type(p)
Out[10]:
In [11]:
dir(p.data)
Out[11]:
In [12]:
p.data
Out[12]:
In [13]:
trace = go.Scatter(
x = df.index,
y = df.iloc[:,1],
mode = 'markers'
)
data = [trace]
# Plot and embed in ipython notebook!
py.iplot(data, filename='basic-scatter')
Out[13]:
In [ ]: