Python SNS Heatmap未完全显示X标签
在Visual Studio Python代码中,我正在尝试为我的数据功能创建热图。该功能名称有时很长,这会导致X轴上的标签有时会部分可见(但不是全部)。我尝试旋转,但这使得标签的订购不正确,并导致标签文本之间有些重叠。以下是我的代码和热图输出。如何解决这个问题?
pyplot.figure(figsize=(20,20))
g=sns.heatmap(df.corr(), vmin=df.corr().values.min(),
vmax=1, square=True, cmap="YlGnBu", linewidths=0.1,
annot=True, annot_kws={"fontsize":4},
xticklabels=1, yticklabels=1)
g.set_xticklabels(g.get_xticklabels(), fontsize = 7)
g.set_yticklabels(g.get_yticklabels(), rotation = 0, fontsize = 7)
pyplot.show()
我还想问是否有一种方法可以使单元格中的值更为明显,因为当我增加字体大小时,单元格中的值重叠。
In visual studio python code, I am trying to create a heatmap for my data features. The feature name is sometimes long, and this causes the label on the x-axis to be partially visible sometimes (but not all of it). I tried rotation but this makes the ordering of the labels incorrect and results in some overlap between labels text. Below is my code and heatmap output. How to solve this issue?
pyplot.figure(figsize=(20,20))
g=sns.heatmap(df.corr(), vmin=df.corr().values.min(),
vmax=1, square=True, cmap="YlGnBu", linewidths=0.1,
annot=True, annot_kws={"fontsize":4},
xticklabels=1, yticklabels=1)
g.set_xticklabels(g.get_xticklabels(), fontsize = 7)
g.set_yticklabels(g.get_yticklabels(), rotation = 0, fontsize = 7)
pyplot.show()
I also would like to ask if there is a way to make the values in the cells more visible possibly by making it bold, because when I increase the font size, the values in the cells overlap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论