from IPython.display import HTML
HTML('' )
import plotly
plotly.__version__
import plotly.plotly as py
import plotly.tools as tls
tls.embed("https://plot.ly/~randal_olson/10/")
# OR
#tls.embed('randal_olson',10)
randal_olson10 = py.get_figure("https://plot.ly/~randal_olson/10")
# OR
#py.get_figure('randal_olson',10)
randal_olson10
print randal_olson10.to_string()
randal_olson10_data = randal_olson10.get_data()
randal_olson10_data
X = [trace['x'][0] for trace in randal_olson10_data]
Y = [trace['y'][0] for trace in randal_olson10_data]
NAME = [trace['name'] for trace in randal_olson10_data]
zip(X,Y,NAME) # print to screen as tuple
from plotly.graph_objs import Data, Layout, Figure
from plotly.graph_objs import Scatter, Marker, Line
from plotly.graph_objs import XAxis, YAxis
scatter = Scatter(
x=X, # x-coordinates
y=Y, # y-coordinates
mode='markers', # show just markers pts
name='', # no name (which appear on the side of the cursor)
text=NAME, # list degree names in a text block on hover
marker= Marker(
size=18,
color='rgb(142, 124, 195)',
opacity=0.7, # slightly transparent pts
line=Line(
color='white', # line around marker pts
width=0.5
)
)
)
data = Data([scatter]) # package into Data object (accepts a list)
layout = Layout(
title=randal_olson10['layout']['title'], # original title
xaxis= XAxis(
title=randal_olson10['layout']['xaxis']['title'] # original x-axis title
),
yaxis= YAxis(
title=randal_olson10['layout']['yaxis']['title'] # original y-axis title
),
showlegend=False, # remove legend
hovermode='closest', # show closest pt on hover
autosize=False, # custom size
width=700,
height=525
)
fig = Figure(data=data, layout=layout)
py.iplot(fig, filename='randal_olson10-remake')
from IPython.display import display, HTML
import urllib2
url = 'https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css'
display(HTML(urllib2.urlopen(url).read()))