我可以使用curdoc选项获得功能,然后使用“bokeh serve bokehcode.py”,然后让我的烧瓶代码(称为app.py)引用此bokeh图。 但是我需要一个包含bokeh部分的python代码,我遇到了一个问题,那就是让按钮点击来调用更新我的绘图/图形的函数。我一整天都没怎么走运
为了简单起见,我删除了所有的功能(甚至是烧瓶部分),并在下面放了一个简化的代码,我需要在没有curdoc的情况下使用选项(主要是customjs回调?)。然后,我可以将其扩展到我的功能
from bokeh.models.widgets import TextInput,Button,Paragraph
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.plotting import figure
inptxt = TextInput()
displaytxt = Paragraph()
button = Button()
p = figure(plot_width=400, plot_height=400)
def myfunc():
displaytxt.text=inptxt.value
p.xaxis.axis_label = inptxt.value
button.on_click(myfunc)
layout=column(inptxt,displaytxt,button,p)
curdoc().add_root(layout)
在我的实际代码中,“myfunc()”会做很多事情,包括一些机器学习的东西,然后它会更新绘图。我希望在单击按钮时调用这个myfunc,并更新图(p),并且我希望在不使用curdoc的情况下实现它。非常感谢您为我们提供的帮助
相关问题 更多 >
编程相关推荐