Seaborn:如何将值/文本放在多图条形图中-Python

时间:2019-05-21 13:10:43

标签: python pandas matplotlib seaborn

使用seaborn在python中,如何将数字放在多图上?

我想将图1的%复制到多图图(图2)

图1的代码

import seaborn as sns
sns.barplot(y='y', x='x', data=df, color='black')

for i in ax.patches:
# get_x pulls left or right; get_height pushes up or down
ax.text(i.get_x()+0.2, i.get_height()+.001, \
str(round((i.get_height())*100, 1))+'%', fontsize=20,
color='dimgrey')

graph 1

图2的代码

import seaborn as sns
sns.factorplot(y='y', x='x', col='z', data=df, color='black',kind='bar')

graph 2

0 个答案:

没有答案