[英]Bokeh plot won't update
I'm new to Bokeh and was wondering if anyone could help tell me why my plot is not updating? 我是Bokeh的新手,我想知道是否有人可以告诉我为什么我的情节没有更新? The code can be found here:
该代码可以在这里找到:
pastebin.com/rn36b3aY pastebin.com/rn36b3aY
The code it just supposed to grab some data using the function "get_dataset", plot a bar chart, and let me update the plot using a dropdown box and slider. 它只是使用功能“ get_dataset”获取一些数据,绘制条形图,然后让我使用下拉框和滑块更新该图的代码。 Can anyone tell me why the plot is not updating?
谁能告诉我为什么情节没有更新? I can provide the data if it would be helpful.
如果有帮助,我可以提供数据。 Thanks!
谢谢!
can you post a simplified version of your program with data? 您可以发布带有数据的程序的简化版吗?
I suspect your plot might not be updating, because in your callback functions you use dataset_select.value and samples_slider.value to update the data. 我怀疑您的绘图可能不会更新,因为在回调函数中,您使用了dataset_select.value和samples_slider.value来更新数据。 But these contain the values from before changing the Slider/Select.
但是这些包含更改滑块/选择之前的值。 You should use the new argument.
您应该使用新的参数。
See if this works: 查看是否可行:
def update_select_samples_or_dataset(attrname, old, new):
global X, Y
dataset = new
n_samples = int(samples_slider.value)
asdata = get_dataset(dataset, n_samples)
X = asdata[['aspects','importance']].as_matrix()
source.data = dict(x=X[:,0], y=X[:,1])
def update_slider_samples_or_dataset(attrname, old, new):
global X, Y
dataset = dataset_select.value
n_samples = int(new)
asdata = get_dataset(dataset, n_samples)
X = asdata[['aspects','importance']].as_matrix()
source.data = dict(x=X[:,0], y=X[:,1])
dataset_select.on_change('value', update_select_samples_or_dataset)
samples_slider.on_change('value', update_slider_samples_or_dataset)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.