☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Can not change data.source in python by callback

Community Support
1113
1113

I am working on a tool for manual classification which changes the property of certain dot(color in my case) chosen in a scatter plot by bokeh. I changed the source data in callback by s.data = d2 and s.change.emit() but both failed. I thought such operation will change source.data, but when I print source.data, actually nothing happens. The dots’ color in the plot changes as expected though. Here is my related code:

DF = pd.read_csv(csv_path)
s = ColumnDataSource(DF_file)
p = figure(plot_width=500, plot_height=500, tooltips=TOOLTIPS,tools="lasso_select, tap", title="manual classification")
circles = p.circle('x', 'y', color='color', size=10, source=s, line_alpha=0.6,fill_alpha=0.6)
s.callback = CustomJS(args=dict(s1=s), code="""
    var inds = cb_obj.selected.indices;
    var d1 = s1.data;

    for (var i = 0; i < inds.length; i++) 
    {d1['color'][inds[i]] = 'green';} 

    s1.change.emit();
""")

(Sorry for asking about this question at the same time at stack overflow and here, but I am in a hurry for a task.)

⌁   Link to post

End of archived discussion · Replies are disabled