python - 用逗号分隔符注释数据点
问题描述
我想在我的图表上注释数据点,并在每 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)
解决方案
将最后一行更改为:
f'R {round(i.get_height(),2):,}', fontsize=40, color='black',rotation=55)
推荐阅读
- django - 依赖/链式下拉列表在模式下不起作用
- reactjs - 删除 Y 轴线,但保留图表中的值
- java - 用于 Linux 的 Gradle/Java 启动脚本不可执行
- javascript - 使用云功能更新文档时的事务延迟
- angular - 如何在 Angular 中正确订阅 Observable
- html - 高度为 100% 的页面。嵌套的 div 溢出-y 不起作用
- ms-access - 如何在子表单中显示搜索查询的结果(通过单击“搜索”按钮完成)?
- sql - NOT IN 在 Listagg 函数中没有按预期工作
- python - Python:如何在不使用 median() 调用的情况下读取 .txt 数字文件以查找所述数字的中位数?
- python - 修改熊猫条形图的轴标签