Kyle
Kyle

Reputation: 193

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!

Upvotes: 0

Views: 889

Answers (1)

user7435037
user7435037

Reputation: 343

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)

Upvotes: 1

Related Questions