熊猫使用Bokeh服务器?

时间:2017-03-06 18:08:58

标签: python bokeh

是否可以在不使用show()的情况下在Bokeh中显示和更新Pandas图?这个在线有什么例子吗?我似乎找不到任何东西。例如,像:

def bar_plot(fig, source):
    p = pd.DataFrame()
    p = p.from_dict(source.data)

    fig = p.plot.bar()
    return fig

def update_data():
    data = source.data
    data['y'] = random.sample(range(0,100),len(data['y']))
    source.data = data

button.on_click(update_data)
source = ColumnDataSource(data)

fig = bar_plot(fig, source)
layout = layout([[button,fig]])
curdoc().add_root(layout)

1 个答案:

答案 0 :(得分:0)

熊猫'内置.plot方法使用Matplotlib生成图像。 Bokeh服务器无法跨Python / JS边界同步或更新MPL图。 Bokeh服务器只能显示和更新使用原生Bokeh API创建的图(即您可以使用Figure.vbar或类似的Bokeh函数从数据框创建条形图。)