2015-10-13 26 views
0
x = [1, 2, 3, 4, 5] 
y = [6, 7, 2, 4, 5] 

# output to static HTML file 
#output_file("lines.html", title="line plot example") 

# create a new plot with a title and axis labels 
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y') 

# add a line renderer with legend and line thickness 
p.line(x, y, legend="Temp.", line_width=2) 

p1 = figure(title="simple line example", x_axis_label='x', y_axis_label='y') 

# add a line renderer with legend and line thickness 
p1.line(x, y, legend="Temp.", line_width=2) 

return components((p, p1)) 

當我運行該測試程序,我得到的誤差,散景部件API失敗,錯誤爲散景10.0與水蟒(蟒2.7)分配

return components((p, p1)) 
File "C:\Working\anaconda_python_27\lib\site-packages\bokeh\embed.py" in components 
ref = plot_object.ref 

Exception Type: AttributeError at /backtest/mavg/ 
Exception Value: 'tuple' object has no attribute 'ref' 
當我通過字典組件

類似錯誤作爲return components({"p":p, "p1": p1})

背景虛化版本10.0蟒蛇通過安裝在你執行它不當,你的代碼對我的作品的窗口64

+0

什麼是回報? – Leb

回答

-1

。我認爲這個問題是您的return components((p, p1))

快速測試使用您的代碼,並有from bokeh.plotting import show誤會我有以下幾點:

enter image description here

取而代之的是returnshow(p1)

+0

「組件」用於在自定義模板中嵌入散景圖,這是常見的事情要做。 – bigreddot

+0

@bigreddot我不確定'組件',但我從python的角度來看它。這就是爲什麼我說'返回組件((p,p1))'很混亂,最後集中在'return'上。 – Leb

0

我不能用Bokeh 0.10重現這一點。我注意到上面的代碼片段沒有定義p2是否有可能你的p2意外地是一個其他的散景圖對象?如果我做一個p2這是一個明確的數字:

from bokeh.plotting import * 
from bokeh.embed import components 
p1 = figure(title="simple line example", x_axis_label='x', y_axis_label='y') 
p1.line(x, y, legend="Temp.", line_width=2) 
p2 = figure(title="simple line example", x_axis_label='x', y_axis_label='y')  
p2.line(x, y, legend="Temp.", line_width=2) 
components((p1, p2)) 

然後components按預期工作。如果您仍然遇到問題,我建議在GH問題跟蹤器上提出問題。