首页 > 解决方案 > 用逗号分隔符注释数据点

问题描述

我想在我的图表上注释数据点,并在每 3 位数字之间使用逗号分隔符返回注释,例如(20,000,000 美元)。

这是到目前为止我有注释的代码

for i in ax_fore.patches:
    # get_x pulls left or right; get_height pushes up or down
    ax_fore.text(i.get_x(), i.get_height(), \
            f'R {round(i.get_height(),2)}', fontsize=40, color='black',rotation=55)

标签: pythonmatplotlib

解决方案


将最后一行更改为:

 f'R {round(i.get_height(),2):,}', fontsize=40, color='black',rotation=55)

推荐阅读