Black Lives Matter. Please consider donating to Black Girls Code today.

How to display both x-axis and y-axis labels in python dendrogram heatmap


I am using the code in

I am unable to display both x-axis and y-axis labels together in the dendrogram heatmap.

Can anyone help me with updated code.


Managed to fix with a indirect trick. :slight_smile:

added the below lines to code
figure[‘layout’][‘yaxis’][‘ticktext’] = np.asarray(labels)
figure[‘layout’][‘yaxis’][‘tickvals’] = np.asarray(dendro_side[‘layout’][‘yaxis’][‘tickvals’])

and set ‘showticklabels’: True in figure[‘layout’][‘yaxis’].update

Thank you, that was very helpful.

I found that the labels would have a different order, so it would not match with the data shown in the graph, so i change the first line of code to:

figure[‘layout’][‘yaxis’][‘ticktext’] = figure[‘layout’][‘xaxis’][‘ticktext’]