In [94]:
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 [95]:
df = cf.datagen.lines()
df.head()
Out[95]:
Plotting through the plotly
interface
In [96]:
py.iplot([{
'x': df.index,
'y': df[col],
'name': col
} for col in df.columns], filename='simple-line')
Out[96]:
Alternatively, use cufflinks
to access iplot
through pandas
In [97]:
p = df.iplot(kind='scatter', filename='simple-line', asFigure=True)
In [98]:
print(p.to_string())
In [99]:
dir(p)
Out[99]:
In [100]:
py.iplot(p)
Out[100]:
In [ ]:
In [101]:
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'
# print(l['line']['color'])
py.iplot(p)
Out[101]:
In [102]:
p = py.iplot([{
'x': df.index,
'y': df[col],
'name': col
} for col in df.columns], filename='simple-line')
In [103]:
type(p)
Out[103]:
In [104]:
dir(p.data)
Out[104]:
In [105]:
p.data
Out[105]:
In [106]:
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[106]:
In [ ]: