Skip to content Skip to sidebar Skip to footer

How To Format Bokeh Xaxis Ticks With Currency

I'm working on a juypter notebook to make a bullet graph to compare two values. The plot renders but I would like to format the xaxis tickers to show currency. This is what I hav

Solution 1:

Believe it or not, but this seems to work only for USD currency. I could not get it working with the Euro-currency symbol. Is there any special trick?

For example, the following code is working:

    plot.handles['yaxis'].formatter = NumeralTickFormatter(format="0,0 $")

while this one is not producing any currency symbols:

    plot.handles['yaxis'].formatter = NumeralTickFormatter(format="0,0 €")

Solution 2:

The code just needs a little more help.

from bokeh.models import Label, Title, NumeralTickFormatter

Then add another assignment to the xaxis

p.xaxis[0].formatter = NumeralTickFormatter(format="$0")

Below is the new graph:

enter image description here

Solution 3:

This code gives a thousand format to y axis in bokeh:

p.yaxis[0].formatter = NumeralTickFormatter(format="0,0")

Solution 4:

With bokeh==2.2.0 I had some issues getting @PaLi's to work. Ultimately what I wanted was something like: "$500k" instead of "$500,000". Using the suggestion of PrintfTickFormatter, I got the following to work:

p.xaxis[0].formatter = PrintfTickFormatter(format="$%ik")

Post a Comment for "How To Format Bokeh Xaxis Ticks With Currency"