A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/introduction-to-bokeh-in-python/ below:

Introduction to Bokeh in Python

Introduction to Bokeh in Python

Last Updated : 24 Jul, 2025

Bokeh is a Python interactive data visualization. Unlike Matplotlib and Seaborn, Bokeh renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity.
 

Why Use Bokeh?

Some of the important features of Bokeh are given below:

Interfaces in Bokeh

Bokeh is a powerful Python library used to create interactive and beautiful visualizations for the web. It provides two main interfaces depending on your needs:

High-Level Interface: bokeh.plotting

This is the most commonly used and beginner-friendly interface. It's designed to help you quickly create standard plots using simple methods.

Example:

Python
from bokeh.plotting import figure, show, output_file
output_file("line_plot.html")

p = figure(title="Line Plot", x_axis_label='X', y_axis_label='Y')
p.line([1, 2, 3], [4, 6, 2], line_width=2)
show(p)

Output

Interactive line between three points

Explanation:

Low-Level Interface: bokeh.models

Bokeh makes it easy to build interactive apps using built-in UI components such as Slider, Button, Select (dropdown), TextInput and CheckboxGroup. These widgets allow users to dynamically interact with your plots, enabling real-time updates and a more engaging data exploration experience.

Example : Interactive Line Plot

Python
from bokeh.layouts import column
from bokeh.models import Slider
from bokeh.plotting import figure
from bokeh.io import curdoc

p = figure(title="Interactive Line")
line = p.line([1, 2, 3], [2, 4, 6])

slider = Slider(start=1, end=5, value=1, step=0.1, title="Scale")

def update(attr, old, new):
    factor = slider.value
    line.data_source.data = {'x': [1, 2, 3], 'y': [i * factor for i in [2, 4, 6]]}

slider.on_change('value', update)
curdoc().add_root(column(slider, p))

Output

Line updates as you move the slider

Explanation:

Related articles:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4