import plotly.plotly as py
import plotly.graph_objs as go
from IPython.display import Image
data = [
go.Scatter3d(
x=[1,2,3],
y=[3,4,5],
z=[1,3,4]
)
]
plot_url = py.plot(data, filename='simple-3d', auto_open=False)
plot_url
u'https://plot.ly/~etpinard/3222'
s = plot_url.split('/')
workspace_url = '/'.join(s[0:3]) + '/' + s[4] + '/' + s[3]
workspace_url
u'https://plot.ly/3222/~etpinard'
Image('http://i.imgur.com/Qv9oIa2.png', width=700)
fig = py.get_figure(plot_url)
camera_position = fig['layout']['scene']['cameraposition']
camera_position
[[0.44497056472787216, -0.4849466666359093, -0.7188785326572444, -0.22369975934060865], [0, 0, 0], 2.165063509461097]
new_data = [
go.Scatter3d(
x=[1,2,3,4],
y=[3,4,5,6],
z=[1,3,4,5]
)
]
new_fig = dict(
data=new_data,
layout=dict(
scene=dict(
cameraposition=camera_position
)
)
)
py.iplot(new_fig, filename='simple-3d-with-camera-position')
About Plotly
Big thanks to
from IPython.display import display, HTML
import urllib2
display(HTML(urllib2.urlopen('https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css').read()))