Search code examples
pythonbokeh

Formatting Bokeh x axis from decimal to percentage with PrintfTickFormatter


I am new to Bokeh and am currently trying to change the x axis of a histogram from decimal based to percentage based. I have been trying to use PrintfTickFormatter but I am apparently missing something. When I try both of the below line of code I receive no output. I tried tweaking the format declaration and I did achieve a percentage, but it was translating the decimals as < 1% or rounding to 1%. Any thoughts on how to fix? I have seen a few different posts on SO, but none seem to directly apply

fig.xaxis.formatter = PrintfTickFormatter(format='0 %')

Solution

  • I was able to solve the issue via the below:

    from bokeh.models import NumeralTickFormatter
    
    fig.xaxis.formatter = NumeralTickFormatter(format='0 %')