Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Camera fly doesn't work in plotly.offline with python? help please;)

Hi! Can anyone spot an error in the following code? The idea is to animate a camera fly above some surface. The code seems to work in a jupyter notebook, but the animation gets really slow. In an offline mode simply nothing changes…;( Frustration x() Any ideas?: please?:wink:

import plotly
from plotly.offline import download_plotlyjs, plot

#yes, i actually do have m credentials here’’, api_key=’’)

x=np.zeros(len(y))#([i*2, i*2+1])

z=[[cz,cz] for cz in z],
x=[[cx,cx+1] for cx in x],
y=[[cy,cy] for cy in y],
colorscale=[ [i, ‘rgb(100,100,255)’] for i in np.arange(0,1.1,0.1) ],

malpha=[float(xx)/180*3.1415 for xx in malpha]

for ii in malpha:
mcam= dict(
up=dict(x=-np.sin(ii), y=0, z=np.cos(ii)),
center=dict(x=0, y=0, z=0),
eye=dict(x=2.5np.cos(ii), y=0, z=2.5np.sin(ii)),
mfr.append(dict(layout= dict(scene=dict(camera= mcam),title=(‘Cur angle:’+str(ii/3.1415*180))) ))

cam0 = dict(
up=dict(x=0, y=0, z=1),
center=dict(x=0, y=0, z=0),
eye=dict(x=2.5, y=0, z=0)

fig = {‘data’:traces,
‘layout’:{ ‘scene’:{‘camera’:cam0},
‘updatemenus’: [{‘type’: ‘buttons’,
‘buttons’: [{‘label’: ‘Play!’, ‘method’: ‘animate’, ‘args’:[None]}]}],
‘title’:‘Ribbon Plot’} }

@kostjia Your animation works fine with iplot: With your code for updatemenus it was slow because you didn’t set frame duration and it played with the default duration=500, which is indeed very slow.

However plot(fig) generates a static plot. I couldn’t find any reason for this behaviour.
It appears that offline animation works either with iplot or with plot. When I animate a surface it works with plot, but not with iplot. I opened an issue here but no answer or fix yet.

1 Like

@empet Thanks for your help! The reason i used plot is because although it works with iplot it’s still to slow even if you set the frame duration… My goal was a smooth flight with more data and more frames (yes, i also tried setting transition times), which does not seem to be possible with iplot…