Hi!
Can’t to set up slider for 3d volume plot. Do everything as in example of MRI. What am i do wrong?
fig = go.Figure(frames=[go.Frame(data=go.Surface(
z=poro[k],
surfacecolor=poro[nz-1-k],
cmin=poro[np.nonzero(poro)].min(), cmax=poro.max()
),
name=str(k) # you need to name the frame for the animation to behave properly
)
for k in range(nz)])
Add data to be displayed before animation starts
fig.add_trace(go.Surface(
z=poro[k],
surfacecolor=poro[nz-1],
colorscale='RdBu',
cmin=poro[np.nonzero(poro)].min(), cmax=poro.max(),
colorbar=dict(thickness=20, ticklen=4)
))
def frame_args(duration):
return {
"frame": {"duration": duration},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": duration, "easing": "linear"},
}
sliders = [
{
"pad": {"b": 100, "t": 60},
"len": 0.9,
"x": 0.1,
"y": 0,
"steps": [
{
"args": [[f.name], frame_args(1)],
"label": str(k),
"method": "animate",
}
for k, f in enumerate(fig.frames)
],
}
]
Layout
fig.update_layout(
title='Slices in volumetric data',
width=1000,
height=1200,
scene=dict(
zaxis=dict(nticks=5, range=[1,nz], autorange=False),
aspectratio=dict(x=1, y=1, z=1),
),
updatemenus = [
{
"buttons": [
{
"args": [None, frame_args(nz)],
"label": "▶", # play symbol
"method": "animate",
},
{
"args": [[None], frame_args(0)],
"label": "◼", # pause symbol
"method": "animate",
},
],
"direction": "left",
"pad": {"r": 100, "t": 70},
"type": "buttons",
"x": 0.1,
"y": 0,
}
],
sliders=sliders
)
fig.show()