我正在尝试创建一个水平seaborn条形图,y轴为整数刻度。当我尝试它时,我得到以下错误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以解决此问题
相关问题 更多 >
编程相关推荐