2015-08-22 34 views
18

我似乎無法從散景條形圖中刪除工具欄。儘管設置工具參數(或「」)我總是結束與背景虛化的標誌和一個灰色的線,例如與此代碼:Python散景:從圖表中刪除工具欄

from bokeh.charts import Bar, output_file, show 

# prepare some data 
data = {"y": [6, 7, 2, 4, 5], "z": [1, 5, 12, 4, 2]} 

# output to static HTML file 
output_file("bar.html") 

# create a new line chat with a title and axis labels 
p = Bar(data, cat=['C1', 'C2', 'C3', 'D1', 'D2'], title="Bar example", 
       xlabel='categories', ylabel='values', width=400, height=400, 
       tools=None) 

# show the results 
show(p) 

然而,當我嘗試用背景虛化情節一樣,它運行完美,工具欄消失了,例如與此代碼:

from bokeh.plotting import figure, output_file, show 

output_file("line.html") 

p = figure(plot_width=400, plot_height=400, toolbar_location=None) 

# add a line renderer 
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2) 

show(p) 

有誰知道我在做什麼錯了?

回答

30

如果你想刪除的標誌和工具欄,你可以這樣做:

p.toolbar.logo = None 
p.toolbar_location = None 

希望這樣可以解決你的問題

+9

看起來像p.toolbar.logo =無現在正確 – derchambers

+0

如何從gridPlot中移除工具欄,從中刪除沒有效果,刪除gridplot是不可能的:AttributeError:'Column'對象沒有屬性'toolbar' – user3598726

2

編輯:

我第一次誤讀你的問題 - 我很抱歉。

高級圖表API類返回一個Plot對象。爲了消除工具欄,你必須設置toolbar_location屬性劇情對象爲無上,如:

...

p = Bar(data, cat=['C1', 'C2', 'C3', 'D1', 'D2'], title="Bar example", 
      xlabel='categories', ylabel='values', width=400, height=400, 
      tools=None) 
p.toolbar_location=None 

...

OLD答:

您想要的:tools = False

每個用戶指南的通用高級圖表參數:

...

工具(STR或布爾):啓用或圖表

中禁用的工具...

http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

+0

我也嘗試過(在括號內提到說_False_和_'__也不起作用)。但你是對的,根據指南它應該工作。不幸的是,它仍然給我的標誌和水平線... – Arkady

+0

你使用什麼版本的散景? –

+0

'bokeh .__ version__'給了我'0.9.2' – Arkady