繁体   English   中英

Seaborn barplot - 将 y 轴设置为整数刻度

[英]Seaborn barplot - Set y-axis as Integer Ticks

我正在尝试创建一个以 y 轴为整数刻度的水平 seaborn 条形图。 当我尝试它时,我收到以下错误TypeError: unsupported operand type(s) for /: 'str' and 'int' 整数在列表y=['100', '200']中引用,所以我认为它们会被解释为字符串。 如果我向整数添加一个或多个字母,它可以正常工作,但不是我想要的所需标签。 如何使用整数列表作为 y 轴刻度并避免此错误?

工作:

f, ax = plt.subplots(figsize=(6, 2))

sns.barplot(y=['100', '200'], x=[100, 75],
            color="#e9ffe1", orient='h')

plt.tight_layout()
plt.show()

作品:

f, ax = plt.subplots(figsize=(6, 2))

sns.barplot(y=['100s', '200s'], x=[100, 75],
            color="#e9ffe1", orient='h')

plt.tight_layout()
plt.show()

在此处输入图片说明

期望输出:

在此处输入图片说明

升级到 Seaborn 0.10 以解决问题。

pip install seaborn --upgrade

暂无
暂无

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

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