简体   繁体   English

如何使更大的热图更具可读性

[英]How to make bigger Heatmap more readable

corrmat is correlation dataframe with 37 columns and 37 rows corrmat 是具有 37 列和 37 行的相关数据框

Code:代码:

f, ax = plt.subplots(figsize=(30,25))
sns.heatmap(corrmat,vmax=0.8,square=True)

I am not able to change the rotation of labels and it is creating mess as no.我无法改变标签的旋转,它正在制造混乱。 of variables used for correlation matrix is more in number.用于相关矩阵的变量数量更多。

Let me know how to make below heatmap more readable让我知道如何使下面的热图更具可读性

Heatmap(37*37)热图(37*37)

Seaborn is built on top of the matplotlib library. Seaborn 建立在 matplotlib 库之上。 So, to rotate labels, you'll need to access the axis object and rotate it.因此,要旋转标签,您需要访问轴对象并旋转它。

Something like this might work:像这样的事情可能会奏效:

 for tick in ax.get_xticklabels():
     tick.set_rotation(45)

You can similarly rotate y-axis labels and calibrate the rotation angles using the number.您可以类似地旋转 y 轴标签并使用数字校准旋转角度。

If you have also done an import matplotlib.pyplot like this:如果您还像这样导入了matplotlib.pyplot

import matplotlib.pyplot as plt

You can specify the following code after you create the heatmap to set the degree of label rotation of both y and x axis.您可以在创建热图后指定以下代码来设置 y 和 x 轴的标签旋转度数。

plt.yticks(rotation= 0)
plt.xticks(rotation=90)

You can play around with the exact number of rotation until you are happy with how it looks.您可以使用确切的旋转次数,直到您对它的外观感到满意为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM