Showing extra data in a heatmap with hovertemplate and customdata

I got a solution in Does plotly support customdata with heatmaps? , Iā€™m reposting it here:

library(plotly)
mat <- matrix(1:100,10,10);
plot_ly(z=mat, type="heatmap", customdata=apply(mat,1, as.list), hovertemplate="%{customdata}<extra></extra>")
2 Likes