简体   繁体   中英

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? The code can be found here:

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. 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. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM