I have several questions about labeling for
import pandas as pd
import numpy as np
import seaborn as sns
m = np.random.rand(50, 50)
df = pd.DataFrame(m, columns=range(4123, 4173), index=range(4123, 4173))
I had the exact same issue with the labels on the y-axis being rotated and found a solution.
The issue is that if you do
plt.yticks(rotation=0) like suggested in the question you referenced, it will rotate the labels on your colobar due to the way
To solve it and rotate the right labels, you need to reference the
Axes from the underlying
Heatmap and rotate these:
cg = sns.clustermap(df, metric="correlation") plt.setp(cg.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
For your other question about the colorbar placement, I don't think this is supported at the moment, as indicated by this Github issue unfortunately.
And finally for the hierarchical clustering distance values, you can access the linkage matrics for rows or columns with:
cg = sns.clustermap(df, metric="correlation") cg.dendrogram_col.linkage # linkage matrix for columns cg.dendrogram_row.linkage # linkage matrix for rows