Andrea Ciufo
Andrea Ciufo

Reputation: 369

What are indices in Bokeh?

Indices are an attribute of the class Selection.

From the Bokeh Documentation:

"They represent all the indices included in a selection."

Selection came from the module bokeh.models a group of "building block" classes.

enter image description here

I can't find in the documentation an exaustive "indices" definition.

What are indices? How to use them in Bokeh?

I supposed that should be considered like the index of ColumnDataSource, or a DataFrame, but I am not sure about that.

I am not sure because, reading the documentation bokeh.models.sources, ColumnDataSource doesn't have any indices parameters unlike pandas.DataFrame

The question raised after reading and studying that question.

Upvotes: 0

Views: 664

Answers (1)

bigreddot
bigreddot

Reputation: 34568

Bokeh selection indices are sequences containing integer index values into the columns of a ColumbnDataSource. The represent which (if any) of the points drawn from a data source have been selected. For instance if we plot:

p.circle(x=[1,2,3,4,5], y=[10, 20, 30, 40, 50])

and then use a box selection tool to select just the left-most two points (1, 10) and (2, 20) on the plot, then the value of source.selection will be [0, 1]. Or if we select just the right-most point (5, 50) then the selection indices will be [4], etc.

Upvotes: 1

Related Questions