StormsEdge
StormsEdge

Reputation: 885

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 %')

Upvotes: 2

Views: 4847

Answers (2)

Matthew Cox
Matthew Cox

Reputation: 1194

As of bokeh 2.3.2, current method is:

from bokeh.models.formatters import NumeralTickFormatter

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

Upvotes: 0

StormsEdge
StormsEdge

Reputation: 885

I was able to solve the issue via the below:

from bokeh.models import NumeralTickFormatter

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

Upvotes: 10

Related Questions