Reputation: 4991
Cant find a working example of using Radio button group ( Adding Interaction ). In the documentation there is an example how to create the group, but how can I use it?
For example how can I create a figure with 2 radio button so if i click the one a plot is showed and if i click the other another plot is showed.
Upvotes: 3
Views: 8476
Reputation: 61
Define the group:
from bokeh.models.widgets import RadioButtonGroup
radio_button_group = RadioButtonGroup(labels=['Plot1', 'Plot2'], active=0)
Use the following line if you want to act immediately when the radio button is pressed:
radio_button_group.on_change('active', lambda attr, old, new: update())
The active choice can be accessed in your update() function under:
radio_button_group.active
Note the values are enumerated: 0 for 'Plot1' and 1 for 'Plot2'
Upvotes: 6