Bokeh Tutorial

1.6 Layout

Exercise: Wrap your visualizations in functions

Wrap each of the previous visualizations in a function in a python file (e.g. viz.py):

  • Climate + Map: climate_map()
  • Legend: legend()
  • Timeseries: timeseries()

In [1]:
# Import the functions from your file
from viz import climate_map, legend, timeseries

In [2]:
# Create your plots with your new functions
climate_map = climate_map()
legend = legend()
timeseries =  timeseries()

In [3]:
# Test the visualizations in the notebook

In [4]:
from bokeh.plotting import show, output_notebook

In [5]:
output_notebook()
show(climate_map)


BokehJS successfully loaded.

In [6]:
show(legend)



In [7]:
show(timeseries)


Exercise: Layout your plots using hplot and vplot


In [8]:
from bokeh.plotting import vplot, hplot

In [9]:
# Create layout
map_legend = hplot(climate_map, legend)
layout = vplot(map_legend, timeseries)

In [10]:
# Show layout
show(layout)


Exercise: Store your layout in an html page


In [11]:
from bokeh.plotting import output_file

In [12]:
#output_file("climate.html")

In [13]:
show(layout)