2017-04-03 73 views
0

我正在运行的Python在Jupyter笔记本电脑和我有以下的代码在笔记本运行良好:如何让我的散景Boxplot显示y轴上所有刻度线的值?

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) 

我的问题是,y轴显示下列值和刻度线:

1000- 
    - 
    - 
    - 
    - 
500- 
    - 
    - 
    - 
    - 
    0- 

我想格式化y轴,使值显示如下:

1000 
    900 
    800 
    700 
    ... 
     0 

能将它散景做呢?

回答

0

所以,我有同样的问题,并且发现这种威胁的解决方案:https://stackoverflow.com/a/27878536/2806632

基本上,你要的是没有一个轴创建你的身材,然后用你的格式添加一个轴。东西上线:

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)