2015-01-10 1 views
0

Поэтому у меня есть следующий код, который отлично работает:Почему я не могу назвать Bokeh file_html на гистограмме?

from bokeh.plotting import circle 
from bokeh.resources import CDN 
from bokeh.embed import file_html 

plot = circle([1,2], [3,4]) 

html = file_html(plot, CDN, "my plot") 

html ветры, содержащий HTML строку, которая рисует круг. Однако я не могу сделать то же самое с объектом Bar.

from bokeh.plotting import circle 
from bokeh.resources import CDN 
from bokeh.embed import file_html 

plot = Bar(OrderedDict(tuples)) 

html = file_html(plot, CDN, "my plot") 

Это терпит неудачу с ошибкой:

Traceback (most recent call last): 
    File "./viz.py", line 66, in <module> 
    html = file_html(b, CDN, "my plot") 
    File "/usr/local/lib/python2.7/dist-packages/bokeh/embed.py", line 120, in file_html 
    script, div = components(plot_object, resources) 
    File "/usr/local/lib/python2.7/dist-packages/bokeh/embed.py", line 41, in components 
    ref = plot_object.ref 
AttributeError: 'Bar' object has no attribute 'ref' 

Я предполагаю, что Bar объект не является объектом сюжета. Как я могу включить его в один?

ответ

2

Этот вопрос (с текущей версией Bokeh 0.7.1) был дан ответ here и here.

Учитывая код, следующее должно работать:

from bokeh.charts import Bar 
from bokeh.resources import CDN 
from bokeh.embed import file_html 

plot = Bar(OrderedDict(tuples)) 
plot.show() 
html = file_html(plot.chart.plot, CDN, "my plot") 
1

Просто наткнулся на это. Некоторое время, и определенно в 0.12, исходный код больше не должен генерировать ошибку.

Смежные вопросы