Reputation: 1464
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)
Upvotes: 26
Views: 11904
Reputation: 131
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)
Upvotes: 7
Reputation: 2161
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
Upvotes: 4
Reputation: 885
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:
use_scientific
attrExample (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()
Upvotes: 4
Reputation: 499
You can disable scientific notation with this:
fig = plt.figure(title='xxx', x_axis_type='datetime')
fig.left[0].formatter.use_scientific = False
Upvotes: 26