Bokeh widgets
add interactive components
Last updated
add interactive components
Last updated
One of Bokeh's most unique features is the ability to add widgets that add interactivity to plots. Widgets allow the user to change the view of the plot by making selections, clicking buttons and typing into textboxes.
Buttons allow the user to select or activate code by clicking. In the following code the Button
class is used to create a button that has the text 'click this'
see:
Checkboxes allow the user to make one or more selections. They are used to select individually or mutiple plots when a plot has multiple categories to show or multiple vizualisations. In the following code the CheckboxGroup
class is used to create a checkbox object with three categories. The activate
argument is used to specify which category is default checked when created.
see:
Another selection widget is the dropdown menu. In the following code, a dropdown menu is created from the class Dropdown
.
see:
Radio buttons limits the user's choice to pick just one option, instead of multiple options like the checkbox. The following code shows the construction of such a button. The class `RadioGroup` is to be used to create such. Again `active` is used to activate one special button.
You can use sliders to decrease or increase datapoints or regions in a plot to be viewed. The following code demonstrates creating a simple slider in bokeh using the Slider
object. The start
and end
arguments are used to specify the start and the end of the slider. The value
argument specifies where the slider should start when the slider is generated. With the step
argument one can specify the number of counts by which the slider would increase or decrease when it is moved to the right or left.
See:
In the input text widget the user can type in text which can be linked to the changing output of the plot. The widget can be created using the TextInput
object. The value
argument is used to set the default value.
See:
see: - -