I am trying to animate simple particle trajectories. I have 2 particles currently. Below is a stripped down example of what I am trying to do. At even 2000 frames, the output html is 91 MB and that appears to be scale about n^1.5. For ~2x3x2000 data points I would expect that data itself to take ~100 kB. We appear to be taking 1000 times more than that for the plot.
I was able to turn relayout off and and that cut things down by a factor of 5 or so. Any other suggestions for performance would be appreciated. It would also be a useful thing to add to the docs.
Thank you for your help.
from plotly.offline import init_notebook_mode, plot
import numpy as np
init_notebook_mode()
t = np.arange(2000)
x = np.cos(2.0 * np.pi /365.0 * t)
y = np.sin(2.0 * np.pi /365.0 * t)
z = np.zeros(len(t))
figure = {'data': [{'x': [0, 1], 'y': [0, 0], 'z': [0, 0], 'type': 'scatter3d', 'mode': 'markers',
'marker': {'color': ['#ff7f0e', '#1f77b4'], 'size': [100.0, 20.0]}},
{'x': [0, 1], 'y': [0, 0], 'z': [0, 0], 'type': 'scatter3d', 'mode': 'lines',
'line': {'color': '#1f77b4', 'width': 2.0}}],
'layout': {'autosize': False, 'width': 1000, 'height': 1000, 'showactive': False,
'scene': {'xaxis': {'range': [-1.5, 1.5], 'autorange': False, 'dtick':1},
'yaxis': {'range': [-1.5, 1.5], 'autorange': False, 'dtick':1},
'zaxis': {'range': [-2, 2], 'autorange': False, 'dtick':1},
'aspectratio': dict( x=1, y=1, z=1),
'aspectmode': 'manual',},
'updatemenus': [{'type': 'buttons',
'buttons': [{'args': [None,
{'frame': {'duration': 30, 'redraw': False,
'relayout': False, 'restyle': False},
'fromcurrent': True, 'mode': 'immediate',
'transition': {'duration': 30}
}],
'label': 'Play',
'method': 'animate'},
{'args': [[None], {'frame': {'duration': 0, 'redraw': False,
'relayout': False, 'restyle': False},
'mode': 'immediate', 'transition': {'duration': 0}}],
'label': 'Pause',
'method': 'animate'
}]}]},
'frames': [{'data': [{'x': [0.0, x[i]],
'y': [0.0, y[i]],
'z': [0.0, z[i]], 'type': 'scatter3d'},
{'x': x[:i],
'y': y[:i],
'z': z[:i], 'type': 'scatter3d'}]}
for i in t],
}
plot(figure, validate=False, filename='test_plot.html',) ```