random
June 15, 2019, 3:54pm
1
I would like to use customdata to display additional information on mouse-over on a heatmap.
Does anyone know how to do this?
My code just says undefined with this example:
library(plotly)
plot_ly(
z=matrix(1:100, nrow=100, ncol=100),
type="heatmap" ,
customdata=1:100,
hovertemplate="x: %{x}\ny: %{y}\nz: %{z}\n%{customdata}<extra></extra>"
) %>%
layout(yaxis=list(scaleanchor="x"))
1 Like
random
June 17, 2019, 6:06pm
2
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
random
June 17, 2019, 6:15pm
3
Getting this working seems to be a matter of getting the type conversions right.