Hello all,
Iโm building a heatmap with a cumulative scatter animation to plot important points. When I begin the scatter animation, the heatmap goes away when the scatter animation begins. Iโm drawing my scatter animation in my main figure and my heatmap is drawn as a trace. How can I keep heatmap as a background and have my scatter draw over it? Should I draw my heatmap in the main figure and have my scatter as a trace? Thanks!
data = [go.Scatter(
x=[],
y=[],
mode='markers',
marker=dict(color=scatterDataX)
)]
dataX = list(scatterDf['Time'])
dataY = list(scatterDf['Depth'])
frames = [dict(data= [dict(type='scatter',
x=dataX[:k+1],
y=dataY[:k+1])],
traces= [1],
name='frame{}'.format(k)
)for k in range(1, len(scatterDf))]
layout = go.Layout(
autosize=True,
hovermode='closest'
)
sliders = [dict(steps= [dict(method= 'animate',
args= [[ 'frame{}'.format(k) ],
dict(mode= 'immediate',
frame= dict( duration=100, redraw= False ),
transition=dict( duration= 0)
)
],
label='{:d}'.format(k)
) for k in range(len(scatterDf))],
transition= dict(duration= 0 ),
x=0,#slider starting position
y=0,
currentvalue=dict(font=dict(size=12),
prefix='Point: ',
visible=True,
xanchor= 'center'),
len=1.0)
]
layout.update(updatemenus=[dict(type='buttons', showactive=False,
y=0,
x=1.05,
buttons=[dict(label='Play',
method='animate',
args=[None,
dict(frame=dict(duration=100,
redraw=False),
transition=dict(duration=0),
fromcurrent=True,
mode='immediate'
)
]
)
]
)
],
sliders=sliders)
fig = go.Figure(data=data, layout=layout, frames=frames)
fig.add_heatmap(z=z2, zauto=False, zmin=-1, zmax=1)
fig.update_yaxes(autorange="reversed", range=[5000, -1000])
fig.update_xaxes(range=[0, 2000])
fig.show()