Annotate heatmap without using figure factory

#1

How can I add values to the heatmap below without using figure factory?

I can’t tell in this example (or from documentation) what is actually making the numbers appear in the heatmap cells. Please help!

https://plot.ly/~empet/14772/annotated-heatmap/#/

#2

Hi @cmedhurs,
it would be easie to answer if you provide the code you used for your plot

Greetings,
Alex

#3

Hi @cmedhurs,

The create_annotated_heatmap figure factory draws the text using standard plotly annotations (https://plot.ly/python/text-and-annotations/#adding-text-to-data-in-line-and-scatter-plots).

-Jon

#4

nparray=np.array([[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 16, 15, 26, 166, 133, 71, 74],
[ 100, 123, 105, 101, 148, 283, 161],
[ 141, 116, 108, 146, 172, 317, 222],
[ 129, 113, 152, 179, 242, 345, 372],
[ 518, 544, 514, 500, 653, 906, 815],
[ 828, 747, 772, 793, 1121, 1356, 1170],
[ 544, 445, 494, 500, 665, 1068, 873],
[ 261, 213, 291, 260, 348, 604, 531],
[ 253, 202, 188, 241, 300, 351, 383],
[ 323, 284, 314, 410, 455, 403, 400],
[ 602, 681, 780, 1030, 1238, 1047, 913],
[ 855, 1181, 1136, 1334, 1658, 1281, 1172],
[ 626, 822, 857, 1081, 1174, 922, 695],
[ 319, 417, 451, 522, 569, 437, 270],
[ 122, 133, 185, 254, 190, 165, 95],
[ 3, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0]], dtype=np.int16).tolist()

display(nparray)

layout_heatmap = plotly.graph_objs.Layout(
title=(‘Title’),
scene=dict(xaxis=dict(range=[0,6], title=‘Weekday’), yaxis=dict(range=[0, 24],
title=‘Hour’),zaxis=dict(title=‘Visitors’, range=[0, 3000])))

trace = plotly.graph_objs.Heatmap(z=nparray, text=nparray)
data=[trace]
fig = plotly.graph_objs.FigureWidget(data=data, layout=layout_heatmap)
fig.layout.height = 750
fig.layout.width =750
plotly.offline.iplot(fig)