Resizing a heat map specifically in a marine map of clusters?

I make a cluster heat map on the seashore as follows

import numpy as np
import seaborn as sns
np.random.seed(2)
data = np.random.randn(100, 10)
sns.clustermap(data)

but the lines are compressed:

enter image description here

but if I pass the size of the clustermap function, then it looks awful

enter image description here

Is there a way to increase the size of a portion of a heat map? So that line names can be read, but not stretch parts of the cluster.

+4
source share
1 answer

As @mwaskom commented, I was able to use it ax_heatmap.set_positionalong with the function get_positionto achieve the correct result.

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

np.random.seed(2)
data = np.random.randn(100, 10)
cm = sns.clustermap(data)
hm = cm.ax_heatmap.get_position()
plt.setp(cm.ax_heatmap.yaxis.get_majorticklabels(), fontsize=6)
cm.ax_heatmap.set_position([hm.x0, hm.y0, hm.width*0.25, hm.height])
col = cm.ax_col_dendrogram.get_position()
cm.ax_col_dendrogram.set_position([col.x0, col.y0, col.width*0.25, col.height*0.5])

enter image description here

+4
source

Source: https://habr.com/ru/post/1611698/


All Articles