PlotlyJS.jl
PlotlyJS.jl copied to clipboard
Heatmap with customdata and hovertemplate doesn't display the right info, when size(customdata)=size(z)
Example of heatmap defined such that to display on hover, both the corresponding z-value and a string pointing out, let us say, the data class or category:
using PlotlyJS
customdata = string.(reshape('A':'L', 4, 3))
4×3 Matrix{String}:
"A" "E" "I"
"B" "F" "J"
"C" "G" "K"
"D" "H" "L"
#with this definition we get right data displayed on hover:
pl=plot(heatmap(z = [ 9 11 12 7;
12 8 13 2;
10 13 12 5],
customdata=customdata, #note that size(customdata)=size(z')
hovertemplate="z: %{z}<br>Class: %{customdata[0]}"))
But if we pass as customdata the transposed matrix of the initial one, as one would expect to be normal, i.e. z and customdata have the same size, on hover we get unparsed information:
restyle!(pl, customdata=permutedims(customdata))
The same bug should be fixed for the contour trace, and for
surface, when is plotting a surface defined as a graph of function, z=f(x,y), not a parametric surface, such as sphere. etc.