Python 用逗号分隔符注释数据点

Python 用逗号分隔符注释数据点,python,matplotlib,Python,Matplotlib,我想在我的图表上标注数据点,并返回每个3位之间带有逗号分隔符的标注,例如($20000000) 这是到目前为止我有注释的代码 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=

我想在我的图表上标注数据点,并返回每个3位之间带有逗号分隔符的标注,例如($20000000)

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

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)

将最后一行更改为:

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

将最后一行更改为:

 f'R {round(i.get_height(),2):,}', fontsize=40, color='black',rotation=55)
该方法支持数千个分隔符:

print('${:,}'.format(20000000))
# $20,000,000
该方法支持数千个分隔符:

print('${:,}'.format(20000000))
# $20,000,000