I'm trying to create a horizontal seaborn barplot with the y-axis as integer ticks. When I attempt it I get the following error TypeError: unsupported operand type(s) for /: 'str' and 'int'
. The integers are quoted in a list y=['100', '200']
so I thought they would be interpreted as string. If I add one ore more alphabets to the integers it works fine but not the desired labels I want. How can I use the list of integers as the y-axis ticks and avoid this error?
Does NOT Work:
f, ax = plt.subplots(figsize=(6, 2))
sns.barplot(y=['100', '200'], x=[100, 75],
color="#e9ffe1", orient='h')
plt.tight_layout()
plt.show()
Works:
f, ax = plt.subplots(figsize=(6, 2))
sns.barplot(y=['100s', '200s'], x=[100, 75],
color="#e9ffe1", orient='h')
plt.tight_layout()
plt.show()
Desired Output:
升级到 Seaborn 0.10 以解决问题。
pip install seaborn --upgrade
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.