1

I am making a bubble chart using Bokeh and I'd like to be able to update my plot's x_range, as it can be used for either integers or strings.

If I'm not mistaken, Int ranges will be managed through Range1d and string ones through FactorRange.

I'm trying to do it using the update() function, called whenever a control is used:

plot = figure(y_range=FactorRange(factors=pandata['HostnameIP'].tolist()), plot_height=600, plot_width=700, title="Visualization", toolbar_location="above", tools=[hover, BoxSelectTool(), ResetTool()])
plot.circle(x='x', y='y', source=source, size=7, color="color", line_color=None, fill_alpha="alpha")

controls = [malware, compromise, x_axis]
for control in controls:
    control.on_change('value', lambda attr, old, new: update())

def update():
    df = select_units()
    x_name = axis_map[x_axis.value]

    plot.xaxis.axis_label = x_axis.value

    if x_name == 'Malware':
        plot.x_range=FactorRange(factors=pandata['Malware'].tolist())
        l.children[0].children[1] = plot

# [...]

inputs = widgetbox(*controls, sizing_mode=sizing_mode)
l = layout([
    [inputs, plot],
    [data_table]
], sizing_mode=sizing_mode)

update()

curdoc().add_root(l)
curdoc().title = "Visualization"

According to this SO, this technique should be working, but I'm getting a blank plot instead.

I've also tried this answer, but it looks like figure.set() doesn't exist anymore.

Any ideas on how to do that? I'm still discovering Bokeh.

TYA :)

Community
  • 1
  • 1
Feeloun
  • 55
  • 7
  • Could you provide a minimum working example? – bourneeoo Feb 21 '17 at 19:05
  • Also let's check foundations: are you running `bokeh serve` on this script? You can't generally run Bokeh server apps by executing `python app.py` you have to run it using the Bokeh server e.g. `bokeh serve app.py` – bigreddot Feb 21 '17 at 19:30

0 Answers0