0

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?

user3115933
  • 4,303
  • 15
  • 54
  • 94

1 Answers1

1

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)
Community
  • 1
  • 1
jaumebonet
  • 2,096
  • 1
  • 15
  • 18