Seaborn Countplot集合\u yticklabels

2024-10-03 09:10:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我绘制了一个带有性别的海生计数图,其中包含两个类别(1:男性,2:女性)

fig01 = sb.countplot(x = df.gender.values)

fig01.set_xticklabels(['Male', 'Female'])
fig01.set_yticklabels(['{}M'.format(int(num)) for num in fig01.get_yticks()/1e6]);

代码后面会出现一条警告

<ipython-input-36-4627ceab9a45>:4: UserWarning: FixedFormatter should only be used together with FixedLocator
  fig01.set_yticklabels(['{}M'.format(int(num)) for num in fig01.get_yticks()/1e6]);

然而,countplot看起来不错

enter image description here

我找到了类似问题here的相关答案。帖子中的指南确实提到我需要先处理set_yticks(),然后再处理set_yticklabels()。我很好奇为什么尽管我手动将x_ticklabels()更改为['Male', 'Female],但没有针对set_xticks()的警告消息


Tags: informat警告forget绘制nummale