Hi @Mirk0_98 ,
A solution to add ticklabels is this one:
import plotly.figure_factory as ff
import numpy as np
z = [[i+j for j in range(21)] for i in range(21)]
tickvals= np.arange(len(z[0]))
x, y = np.meshgrid(tickvals, tickvals)
customdata = np.dstack((x,y))
fig=ff.create_annotated_heatmap(z)
fig.update_traces(customdata=customdata,
hovertemplate="x: %{customdata[0]}<br>"+\
"y: %{customdata[1]}<br>z: %{z}")
fig.update_xaxes(tickvals=tickvals, ticktext=["a"]*21, showticklabels=True)
fig.update_yaxes(tickvals=tickvals, ticktext=["a"]*21, showticklabels=True)
fig.update_layout(width=700, height=700)
fig.show()
If you like to have flipped annotations (i.e. to reverse the row order), then replace the
line:
fig.update_yaxes(tickvals=tickvals, ticktext=["a"]*21, showticklabels=True)
with:
fig.update_yaxes(tickvals=tickvals, ticktext=["a"]*21, showticklabels=True, autorange="reversed")
By default, the ff.create_annotated_heatmap() does not display heatmap ticklabels. Thatβs why we performed the update showticklabels=True.
The values in the list /arraytickvals give positions of ticklabels, and those in ticktext, the corresponding labels. I suspect that you want different ticklabels, not just βaβ, like in your minimal example.
customdata and hovertemplate is needed to display the right information on hover. If they are not provided, then on hover youβll see: x=βaβ, y=βaβ, z=j for j in your example range.