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

Hi

I am using the code in https://plot.ly/python/dendrogram/

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

Can anyone help me with updated code.

Thanks
Philge

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’]