I have the code to create my 2D histogram as below. It works for creating a statics chart but I need to create an animated heatmap which change with ‘minute_play’ column. How can I do that? The picture of the data sample and the output are attached. Below is the code I used to create the 2D histogram (heatmap)
multicolor = ["#ffffff","#e2eeff", "#c3d8f9","#80bdff", "#42b0f5",
"#a0e242", "#d1cb1c", "#a06a20", "#872a10", "#630d02", "#000000"]
bins = 100
densities,_,_ = np.histogram2d(heatmap_df.params_pos_x, heatmap_df.params_pos_y, bins=bins)
percentiles = [0,1,10,20,30,40,50,60,70,80,99,100]
bounds = []
for i in percentiles:
bounds.append(np.percentile(np.unique(densities),i))
cmaplist = multicolor
cmap = mpl.colors.LinearSegmentedColormap.from_list(
'Custom cmap',
cmaplist,
len(percentiles))
norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
plt.hist2d(heatmap_df.params_pos_x,
heatmap_df.params_pos_y,
bins = bins,
norm = norm,
cmap = cmap)
cbar = plt.colorbar(ticks = bounds)
plt.show()
I have try to follow this but did not really understand what to do next to migrate my code to this guide
https://plotly.com/python/v3/heatmap-animation/
Quang Dang Hong is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1