Article Complete
AIM
Hands-On Tutorial on Bokeh - Open Source Python Library For Interactive Visualizations
Hands-On Tutorial on Bokeh - Open Source Python Library For Interactive Visualizations

Hands-On Tutorial on Bokeh - Open Source Python Library For Interactive Visualizations

Published Updated

Key takeaways

  • Bokeh is an open-source Python library designed for creating interactive visualisations for modern web browsers.
  • The library allows for the construction of versatile graphics and supports high-performance interactivity with large datasets.
  • Bokeh can be utilised for various applications, including interactive plots, dashboards, and data-driven applications.
  • The implementation process involves installing Bokeh and importing necessary libraries for data manipulation and visualisation.
5 min

Dashboards are collections of bars, charts, and graphs that help us visualize different attributes of a dataset. A dashboard works as a graphical user interface which helps us identify the key performance indicators relevant to the dataset or the particular business model. Python provides different open-source libraries that can help you create your own dashboard with your dataset. Today we will be talking about Bokeh which is an open-source python library for interactive visualizations for the modern web browsers. 

Bokeh provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets. It can be used for different purposes like creating interactive plots, dashboards, and even data-driven applications.

In this article we will discuss:

  1. Creating Bokeh Visualization and Analyzing it.
  2. Creating a Sales Dashboard using Bokeh

Implementation of Bokeh:

Like any other library, we need to install Bokeh for exploring it by pip install bokeh

  1. Importing required libraries

We will import pandas for loading the dataset and will import different functions of bokeh as and when required.

import pandas as pd

from bokeh.plotting import figure, output_file, show

  1. Loading the dataset

We will create a sales dashboard for which we need sales data of a company, here I will use a dataset which contains Sales of a company and different attributes on which it depends.

df = pd.read_csv(‘Advertising.csv’)

df

  1. Creating Visualizations

We will start by creating visualizations and later add them to a single dashboard. Starting with the scatter plots to find the relationship between Sales and the factors governing it.

from bokeh.plotting import figure, output_file, show

output_file("p1.html")

p1 = figure(plot_width=400, plot_height=400)

p1.circle(df['TV'], df['Sales'], size=2, color="navy", alpha=0.5)

show(p1)

As you can see here Bokeh not only creates visualization but also provides different functions as shown in the image, the visualization is highly interactive and downloadable.

Similarly, we will create the visualization for the other two attributes against the Sales.

output_file("p2.html")

p2 = figure(plot_width=400, plot_height=400)

p2.circle(df['Radio'], df['Sales'], size=2, color="navy", alpha=0.5)

show(p2)

output_file("p3.html")

p3 = figure(plot_width=400, plot_height=400)

p3.circle(df['Newspaper'], df['Sales'], size=2, color="navy", alpha=0.5)

show(p3)

Bokeh

As you can see here we have created three scatter plots of Sales(Dependent Variable) vs. Newspaper, TV, Radio( Independent Variable)

Next, we will create the distribution plots according to the ‘Sales’ of all the numerical attributes.

fig1 = figure(plot_width=400, plot_height=400)

fig1.vbar(x=df['Sales'], bottom=0, top=df['TV'],

          color='blue', width=0.75, 

          legend='TV')

           show(fig1)

Bokeh

fig2 = figure(plot_width=400, plot_height=400)

fig2.vbar(x=df['Sales'], bottom=0, top=df['Radio'],

         color='red', width=0.75, 

         legend='Radio')

show(fig2)

Bokeh

fig3 = figure(plot_width=400, plot_height=400)

fig3.vbar(x=df['Sales'], bottom=0, top=df['Newspaper'],

         color='green', width=0.75, 

         legend='Newspaper')

show(fig3)

Bokeh

Similarly, we can create different types of plots and graphs according to our requirements. 

Next, we will design the layout and show these images in a single dashboard.

  1. Creating a Dashboard

For getting all these images in a single layout we need to define the layout of the dashboard.

We will use the grid layout and visualize the dashboard in a grid format.

from bokeh.layouts import gridplot

grid = gridplot([[p1, p2, p3], [fig1, fig2, fig3]], plot_width=250, plot_height=250)

show(grid)

Bokeh

As you can see in the image we have created a dashboard in a grid layout, it clearly shows the relationship between Sales and the numerical on which it is dependent.

This is just a basic layout/Dashboard which is easily created and can help you start designing dashboards in Bokeh if you are a beginner.

Conclusion:

In this article, we learned about dashboards, how they help us to visualize the key performance indicators. We learned about Bokeh and how we can create dashboards using it, Bokeh is highly interactive and visually appealing. We can use this knowledge to create our own dashboards and visualize it.

Membership

Stay ahead with AI insights.

Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

Subscribe now

AIM Americas

1190 Miraloma Way Suite P, Sunnyvale, CA 94085

AIM India

1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

© 2026 AIM. All rights reserved.