Tsi*_*gis 3 python python-3.x bokeh
随着NumeralTickFormatter(format='0,0')我能得到逗号作为千位分隔符,例如,但我无法找到一个方法来使用空间。
我也尝试使用该language='fi'参数,但这似乎没有帮助,或者我以错误的方式使用它。
据我所知,内置NumeralTickFormatter不支持这一点,因为它所基于的底层第三方 JavaScript 库没有任何显示空格的模式。但是,Bokeh 有一个FuncTickFormatter,它允许您提供自己的 JS 代码段来执行您喜欢的任何格式:
from bokeh.models import FuncTickFormatter
from bokeh.plotting import figure, show, output_file
output_file("formatter.html")
p = figure(plot_width=500, plot_height=500)
p.circle([0, 10], [10, 1000000], size=30)
p.yaxis.formatter = FuncTickFormatter(code="""
parts = tick.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
return parts.join(".");
""")
show(p)
Run Code Online (Sandbox Code Playgroud)
结果是:
| 归档时间: |
|
| 查看次数: |
749 次 |
| 最近记录: |