0
votes

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!

1
How are you trying to run it? Bokeh server apps have to be run with the bokeh command, e.g. bokeh serve --show app.py If you are doing that already, what have you tried already to debug? - bigreddot
Hi, yes I've been using bokeh serve --show app.py. I've put a new, easier to read version here pastebin.com/rn36b3aY. The update is still not working correctly. It looks like this is due to the x=factors on like 57. Dataframe "asdata" has one categorical column (the first column) and one numerical column ( the second column). The numerical column seems to be updating, but not the categorical one. For example, if I switch line 57 to plot.vbar(x='y', width=0.5, bottom=0, top='y', source=source), the plot updates properly ('y' is the numerical column of the dataframe). - Kyle

1 Answers

1
votes

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)