Changing single glyph's property inside a renderer?

I have the following simple example, and I would like to reset the colour property of one of the circles to be red, as a separate process, after the renderer is initialised.

from bokeh.plotting import show

x = [2, 4, 8, 5, 9, 3]
y = [4, 8, 2, 7, 4, 6]
id = ['1001', '1002', '1003', '1004', '1005', '1006']

cds = ColumnDataSource(data={'x': x, 'y': y, 'id': id})

p = figure(width=300, height=200)
renderer ='x', y='y', source=cds, size=5, color='green')

# This is my issue?!
#renderer.glyphs[0].color = 'red'


I’m aware that I can use the following API to achieve the result, but that is not an option considering what I would like to do next.

selected_circle = Circle(fill_alpha=1, fill_color="firebrick", line_color=None)
nonselected_circle = Circle(fill_alpha=0.2, fill_color="blue", line_color="firebrick")

My intention is to target a specific glyph with a JS callback.

If you mean that you would like to control the color for individual circles drawn on the screen, then you will need to put the color data in a column in your CDS and use that column to drive the glyph (the same way you do with the “x” and “y” columns for coordinates). Then you can update individual circles by updating the data in the CDS.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.