I am running Python in Jupyter Notebook and I have the following codes running fine in the Notebook:
from bokeh.charts import BoxPlot, show
from bokeh.io import output_notebook
output_notebook ()
df = myfile2
p = BoxPlot(df, values='Total Spending', label=['Market'],color='Market', marker='square',
whisker_color='black',legend=False, plot_width=800, plot_height=600,
title="Total Spending, February 2017)")
p.xaxis.major_label_orientation = "horizontal"
show(p)
My issue is that the y-axis is displaying the following values and tick marks:
1000-
-
-
-
-
500-
-
-
-
-
0-
I would like to format that y-axis so that the values show up as follows:
1000
900
800
700
...
0
Can it be done in Bokeh?
So, I had the same issue and found a solution in this threat: https://stackoverflow.com/a/27878536/2806632
Basically, what you want is to create your figure without an axis and then add an Axis with your format. Something on the lines of:
from bokeh.models import SingleIntervalTicker, LinearAxis
from bokeh.charts import BoxPlot, show
from bokeh.io import output_notebook
output_notebook ()
df = myfile2
# See that x_axis_type is now None
p = BoxPlot(df, values='Total Spending', label=['Market'],color='Market', marker='square',
whisker_color='black',legend=False, plot_width=800, plot_height=600,
title="Total Spending, February 2017)", x_axis_type=None)
# Interval one, assuming your values where already (0,100,200...)
ticker = SingleIntervalTicker(interval=1, num_minor_ticks=0)
yaxis = LinearAxis(ticker=ticker)
p.add_layout(yaxis, 'left')
# I'm pretty sure you won't need this: p.xaxis.major_label_orientation = "horizontal"
show(p)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.