A Case Study Interactive Data Visualization with Bokeh The - - PowerPoint PPT Presentation

a case study
SMART_READER_LITE
LIVE PREVIEW

A Case Study Interactive Data Visualization with Bokeh The - - PowerPoint PPT Presentation

INTERACTIVE DATA VISUALIZATION WITH BOKEH A Case Study Interactive Data Visualization with Bokeh The Gapminder Data Set In [1]: data.head() Out[1]: Country fertility life population child_mortality gdp \ Year 1964 Afghanistan


slide-1
SLIDE 1

INTERACTIVE DATA VISUALIZATION WITH BOKEH

A Case Study

slide-2
SLIDE 2

Interactive Data Visualization with Bokeh

The Gapminder Data Set

In [1]: data.head() Out[1]: Country fertility life population child_mortality gdp \ Year 1964 Afghanistan 7.671 33.639 10474903.0 339.7 1182.0 1965 Afghanistan 7.671 34.152 10697983.0 334.1 1182.0 1966 Afghanistan 7.671 34.662 10927724.0 328.7 1168.0 1967 Afghanistan 7.671 35.170 11163656.0 323.3 1173.0 1968 Afghanistan 7.671 35.674 11411022.0 318.1 1187.0 region Year 1964 South Asia 1965 South Asia 1966 South Asia 1967 South Asia 1968 South Asia

slide-3
SLIDE 3

Interactive Data Visualization with Bokeh

A Data Exploration Tool

slide-4
SLIDE 4

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Let’s practice!

slide-5
SLIDE 5

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Starting a Basic App

slide-6
SLIDE 6

Interactive Data Visualization with Bokeh

Adding just a plot

In [1]: from bokeh.io import curdoc In [2]: # Create plots and widgets In [3]: # Add callbacks In [4]: # Arrange plots and widgets in layouts In [5]: curdoc().add_root(layout)

slide-7
SLIDE 7

Interactive Data Visualization with Bokeh

Adding just a plot

slide-8
SLIDE 8

Interactive Data Visualization with Bokeh

Adding a slider

# Define a callback taking attr, old, new def update_plot(attr, old, new): yr = slider.value new_data = { # Update date here } source.data = new_data plot.title.text = # new title text # Create a slider slider = Slider(start=1970, end=2010, step=1, value=1970, title='Year') # Add a callback to its value slider.on_change('value', update_plot)

slide-9
SLIDE 9

Interactive Data Visualization with Bokeh

Result for this section

slide-10
SLIDE 10

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Let’s practice!

slide-11
SLIDE 11

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Adding More Interactivity

slide-12
SLIDE 12

Interactive Data Visualization with Bokeh

Adding a Hover Tool

hover.py

  • from bokeh.models import HoverTool

# HoverTool tooltips accepts a list of tuples hover = HoverTool(tooltips=[ ('species name', '@species'), ('petal length', '@petal_length'), ('sepal length', '@sepal_length'), ]) # Include hover in the list of plot tools plot = figure(tools=[hover, 'pan', 'wheel_zoom'])

slide-13
SLIDE 13

Interactive Data Visualization with Bokeh

Adding a Dropdown Menu

from bokeh.models import Select # Define a callback taking attr, old, new def callback(attr, old, new): # Update the plot here # Create a Select widget menu = Select(options=['foo', 'bar', 'baz'], value='foo', title='A menu of options') # Add a callback to its value menu.on_change('value', callback)

slide-14
SLIDE 14

Interactive Data Visualization with Bokeh

The final result

slide-15
SLIDE 15

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Let’s practice!

slide-16
SLIDE 16

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Wrap Up

slide-17
SLIDE 17

Interactive Data Visualization with Bokeh

Recap and Next Steps

  • The bokeh.ploing interface for basic ploing
  • How to customize plots and add layouts and interactions
  • The bokeh.charts interface for very high level charts
  • The power of the bokeh server for creating richly

interactive visualization applications.

hps://bokeh.github.io

slide-18
SLIDE 18

INTERACTIVE DATA VISUALIZATION WITH BOKEH

Congratulations!