25

How can you disable scientific output of numbers on an axis in bokeh? For example, I want 400000 and not 4.00e+5

In mpl: ax.get_xaxis().get_major_formatter().set_scientific(False)

jruizaranguren
  • 12,679
  • 7
  • 55
  • 73
quasiben
  • 1,444
  • 1
  • 11
  • 19

4 Answers4

24

You can disable scientific notation with this:

fig = plt.figure(title='xxx', x_axis_type='datetime')
fig.left[0].formatter.use_scientific = False
ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
korst1k
  • 477
  • 4
  • 11
  • 3
    The code above actually disables it on the vertical y-axis. If you want to disable scientific notation on the horizontal x-axis for a line plot, use: `fig.below[0].formatter.use_scientific = False`. – Contango Jan 01 '19 at 23:00
  • Code and my comment above works with latest version of Bokeh as of 2019-01-01 (v1.0.3). – Contango Jan 01 '19 at 23:00
4

Note that as of Bokeh v0.9.1, Marek's answer will no longer work due to changes in the interface for Charts. The following code (from GitHub) is a fully-functional example of how to turn off scientific notation in a high level chart.

from bokeh.embed import components
from bokeh.models import Axis
from bokeh.charts import Bar
data = {"y": [6, 7, 2, 4, 5], "z": [1, 5, 12, 4, 2]}
bar = Bar(data)
yaxis = bar.select(dict(type=Axis, layout="left"))[0]
yaxis.formatter.use_scientific = False
script, div = components(bar)
print(script)
print(div)

The key lines are:

yaxis = bar.select(dict(type=Axis, layout="left"))[0]
yaxis.formatter.use_scientific = False
Josh Sherick
  • 2,161
  • 3
  • 20
  • 37
4

I was trying to turn off scientific notation from a logarithmic axis, and the above answers did not work for me.

I found this: python bokeh plot how to format axis display

In that spirit, this worked for me:

from bokeh.models import BasicTickFormatter

fig = plt.figure(title='xxx', x_axis_type='datetime',y_axis_type='log')
fig.yaxis.formatter = BasicTickFormatter(use_scientific=False)

rahulv88
  • 101
  • 9
2

To disable the scientific output in Bokeh, use use_scientific attribute of the formatter you use.

You can find more information regarding use_scientific attribute here:

Example (originaly comes from Bokeh issues discussion):

from bokeh.models import Axis
yaxis = bar.chart.plot.select(dict(type=Axis, layout="left"))[0]
yaxis.formatter.use_scientific = False
bar.chart.show()
Marek
  • 815
  • 8
  • 19