Format python bokeh axis display

y-axis ticks seem to be formatting numbers like 500000000 to 5.000e + 8. Is there a way to manipulate the display so that it appears as 500000000?

using python 2.7, bokeh 0.5.2

im trying out the timeseries example on the bokeh tutorials page

In the lesson section "Adj Close" opposite "Date", but I draw "Volume" in "Date"

+3


source to share


2 answers


You must add the option p.left[0].formatter.use_scientific = False

to your code. In a time series tutorial, this would be:



p1 = figure(title="Stocks")
p1.line(
    AAPL['Date'],
    AAPL['Adj Close'],
    color='#A6CEE3',
    legend='AAPL',
)

p1.left[0].formatter.use_scientific = False # <---- This forces showing 500000000 instead of 5.000e+8 as you want

show(VBox(p1, p2))

      

+5


source


You can also use NumeralTickFormatter as shown in the picture below. Other possible values ​​instead of "00" are listed at http://bokeh.pydata.org/en/latest/docs/reference/models.html



import pandas as pd
import numpy as np
from bokeh.plotting import figure, output_file, show
from bokeh.models import NumeralTickFormatter

df = pd.DataFrame(np.random.randint(0, 90000000000, (10,1)), columns=['my_int'])
p = figure(plot_width=700, plot_height=280, y_range=[0,100000000000])
output_file("toy_plot_with_commas")

for index, record in df.iterrows():
    p.rect([index], [record['my_int']/2], 0.8, [record['my_int']], fill_color="red", line_color="black")

p.yaxis.formatter=NumeralTickFormatter(format="00")
show(p)

      

+5


source







All Articles