Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

From Data to Visualization

Building a visualization with Bokeh involves the following steps:

  • Prepare the data
  • Determine where the visualization will be rendered
  • Set up the figure(s)
  • Connect to and draw your data
  • Organize the layout
  • Preview and save your beautiful data creation

This video will explore each step in more detail.

The template below can be used to explore the six building blocks used across this course.

Python
"""Bokeh Visualization Template

This template is a general outline for turning your data into a 
visualization using Bokeh.
"""
# Data handling
import pandas as pd
import numpy as np

# Bokeh libraries
from bokeh.io import output_file, output_notebook
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
from bokeh.layouts import row, column, gridplot
from bokeh.models.widgets import Tabs, Panel

# Prepare the data

# Determine where the visualization will be rendered
output_file('filename.html')  # Render to static HTML, or 
output_notebook()  # Render inline in a Jupyter Notebook

# Set up the figure(s)
fig = figure()  # Instantiate a figure() object

# Connect to and draw the data

# Organize the layout

# Preview and save 
show(fig)  # See what I made, and save if I like it

00:00 There’s several steps to go from data to visualization. These six steps—prepare the data, determine where the visualization is going to be rendered, set up figures, connect to and draw your data, organize the layout, and then preview and save your beautiful data creation—are the steps that you’ll follow each time you make a visualization.

00:20 Let me talk about each one briefly. First, you need to prepare the data. This can be in a separate file if you want, but typically data comes in the form of large tables.

00:31 Those DataFrames can be handled inside of pandas or using something like NumPy. You’ll need to be doing some cleaning, usually, and preparing the data, and then transforming the data to show the types of things that you want to see. Next, you need to determine where the visualization is going to be rendered.

00:48 That would be in a static HTML file or inline inside of a Jupyter Notebook, of which I’ll show you both. Then you need to set up the figures, preparing the canvas—customizing titles, tick marks, backgrounds, et cetera—and then enable the type of user interactions. Step 4 is to connect to and draw your data.

01:07 Select the type of renderer—they’re called glyphs—to give shape to your data. These could be charts, maps, histograms, plots, heat maps, et cetera.

01:18 Then you’ll organize the layout. You can have multiple figures for your visualization, and so those multiple figures can be in a grid-like layout or in tabs.

01:27 And then there’s also ways to link interactions across the figures. The last step is to preview and save your beautiful data creation, either in a browser or a Notebook as we talked about.

01:37 You can then explore those visualizations and examine how you can customize things and then play with all the interactions that you’ve added.

01:45 I’d like to show you a template to give you an idea of all those steps and what they would look like inside your script. First off, in some cases, you’ll be doing your data handling inside of the script.

01:55 Sometimes you’ll do it by importing, so you may find yourself importing pandas or NumPy to do that type of work. After importing those for data handling if needed, you’ll import from the Bokeh libraries. No need to focus on them now. They’ll be in each of the upcoming scripts.

02:10 So, step 1, prepare the data or import the data that you’re going to use. And then step 2, you’ve got to determine where you want the visualization to be rendered.

02:17 So that can be, again, to an output file or you can output to a Notebook. Next, you instantiate a figure() object in step 3.

02:26 Then you connect to and draw the data using glyphs. Step 5 is for organizing the layout, especially if you have multiple visualizations. And last would be previewing and saving using the method show().

02:38 This will act as a template with these six steps for all the upcoming scripts and videos. Next up, time to get Bokeh installed and set up.

Become a Member to join the conversation.