Hello,
I am trying to replicate this example with cone plots. However I get a blank 2d plot without any of the cones. Any idea what is missing?
import numpy as np
import plotly.graph_objects as go
x = y = z = np.arange(5)
pos = np.meshgrid(x, y, z, indexing='ij')
pos = np.array(pos).T.reshape(-1, 3)
n_frames = 10
data_list = list()
for k in range(n_frames):
data_list.append(np.random.rand(pos.shape[0], 3))
go_frames = list()
for k, data in enumerate(data_list):
go_frames.append(go.Frame(data=go.Cone(
x=pos[:, 0],
y=pos[:, 1],
z=pos[:, 2],
u=data[:, 0],
v=data[:, 1],
w=data[:, 2],
colorscale='Jet',
cmax=1e-5,
cmin=0,
sizeref=1),
name=str(k)
))
fig = go.Figure(frames=go_frames)
def frame_args(duration):
return {
"frame": {"duration": duration},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": duration},
}
sliders = [{"pad": {"b": 10, "t": 60},
"len": 0.9,
"x": 0.1,
"y": 0,
"steps": [{"args": [[f.name], frame_args(0)],
"label": str(k),
"method": "animate"}
for k, f in enumerate(fig.frames)]}]
fig.update_layout(
title='Cones',
width=600,
height=600,
scene=dict(
zaxis=dict(range=[0, 460], autorange=False),
aspectratio=dict(x=1, y=1, z=1),
),
updatemenus=[{
"buttons": [{"args": [None, frame_args(50)],
"label": "▶",
"method": "animate"},
{"args": [[None], frame_args(0)],
"label": "◼",
"method": "animate"}],
"direction": "left",
"pad": {"r": 10, "t": 70},
"type": "buttons",
"x": 0.1,
"y": 0}],
sliders=sliders)
fig.show()