@jack @empet @nicolaskruchten I am working on a heatmap chart and trying to update tickvals/ticktext. The chart works but without the ticktext/tickvals update. I tried to set tickmode=“array” also, but it does not work. Please help.
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd, numpy as np
import plotly.express as px
import plotly.graph_objects as go
# generate data
fig_dim = 5 # dimension of heatmap
data_dict = np.random.random((fig_dim, fig_dim))
axis_vec=['A','B','C','D','E']
# print(data_dict)
annotations=[]
for n, row in enumerate(data_dict):
for m, val in enumerate(row):
font_color = '#ffffff' if val<0.25 else '#ffffff' if val>0.75 else '#484848'
record = go.layout.Annotation(
text=str("{:0.2f}".format(val)),
x=m,
y=n,
xref="x1",
yref="y1",
font=dict(color=font_color, size=14),
showarrow=False,
)
annotations.append(record)
dff=data_dict
# create figure object
fig = go.Figure(data=go.Heatmap(z=dff, colorscale='Spectral',),
layout=go.Layout(xaxis_nticks=fig_dim, yaxis_nticks=fig_dim, annotations=annotations))
# update axis tick text but not working.
fig.update_yaxes(tickmode="array", tickvals=axis_vec, ticktext=axis_vec)
fig.update_xaxes(tickmode="array", tickvals=axis_vec, ticktext=axis_vec)
fig.update_layout(margin={'l': 40, 'b': 40, 't': 10, 'r': 0}, hovermode='closest')
fig.show()