Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 向每个单独的栏添加标签_Python_Pandas_Matplotlib_Seaborn - Fatal编程技术网

Python 向每个单独的栏添加标签

Python 向每个单独的栏添加标签,python,pandas,matplotlib,seaborn,Python,Pandas,Matplotlib,Seaborn,产生以下结果: 现在,我想在每个条的末端内侧放置一个注释,注释中的数字与其值相对应。因此,我需要(我认为)遍历每个条,并放置一个具有正确坐标偏移的注释以使其到达那里。但我不知道怎么去那里 更新 请注意,我正在询问有关Seaborn的问题。链接的可能重复项与matplotlib不同。(谢谢@dux和@xg.plt.py)这应该行得通 ax0 = sns.barplot(x='techies', y=df.index, data=df, color = "b", label="techies")

产生以下结果:

现在,我想在每个条的末端内侧放置一个注释,注释中的数字与其值相对应。因此,我需要(我认为)遍历每个条,并放置一个具有正确坐标偏移的注释以使其到达那里。但我不知道怎么去那里

更新 请注意,我正在询问有关Seaborn的问题。链接的可能重复项与matplotlib不同。(谢谢@dux和@xg.plt.py)

这应该行得通

ax0 = sns.barplot(x='techies', y=df.index, data=df, color = "b", label="techies")
示例与示例数据集

values = df.techies.groupby(df.index).mean()
for i, v in enumerate(values):
    ax.text(v,  i-0.1, '%.2f' % v, fontsize=10)

@xg.plt.py为什么这个问题可能会在您建议的副本中得到回答,我觉得大多数用户都希望在单个问题中看到答案实际上,链接答案中的解决方案在这里不起作用,因为这里使用了
seaborn
,和
barplot
的签名与
pyplot.barh
的可能重复签名不同
import seaborn as sns
tips = sns.load_dataset("tips")
ax = sns.barplot(y="day", x="total_bill", data=tips)
for i, v in enumerate(tips.groupby('day').total_bill.mean()):
    ax.text(v,  i-0.1, '%.2f' % v, fontsize=10)