Bokeh交互式添加线条

时间:2016-01-30 12:02:24

标签: bokeh

我想绘制与输入用户相对应的行将通过InputText

给出

代码段,example.py

region = pd.read_csv("region.csv", encoding="utf-8").set_index("plo_region")
TS_LENGTH=360
fig = figure(plot_width=700, plot_height=500, y_axis_type="log",y_range=(10**-2, 10**3))

# callback template
def callback_template(new, table, ts_length):
    # whatever behavior



def callback_region(attr, old, new):
    callback_template(new, region, TS_LENGTH)

    # what to add line in callback function
    curdoc().clear()
    fig.line(x=[1,2,3], y=[1,2,3], legend="sdfds",color="black")
    curdoc().add_root(hplot(inputs, fig))




textInput_region = TextInput(value="", title="region:")
textInput_region.on_change("value", callback_region)


controls = [textInput_region]
inputs = HBox(VBoxForm(controls), width=300)

# put the button and plot in a layout and add to the document
curdoc().add_root(hplot(inputs, fig))
# HOW TO SYNC THE CHANGE ON FIG TO BROWSER ??

所以,如果用户给出了柏林,汉堡和#34;在TextInput框中,它将触发回调函数并在图上绘制两条线。相反,如果用户给出柏林,汉堡,汉诺威和#34;它将绘制三条线。

0 个答案:

没有答案