Exercise

Linked brushing

By sharing the same ColumnDataSource object between multiple plots,
selection tools like BoxSelect and LassoSelect will highlight points
in both plots that share a row in the ColumnDataSource.

In this exercise, you'll plot female literacy vs fertility and population vs fertility in two
plots using the same ColumnDataSource.

After you have built the figure, experiment with the Lasso Select and Box Select tools. Use your mouse to drag a box or lasso around points in one figure, and notice how points in the other figure that share a row in the ColumnDataSource also get highlighted.

Before experimenting with the Lasso Select, however, click the Bokeh plot pop-out icon to pop out the figure so that you can definitely see everything that you're doing.

Instructions

100 XP

Create a ColumnDataSource object called source from the data DataFrame.

Create a new figure p1 using the figure() function. In addition to specifying the parameters x_axis_label and y_axis_label, you will also have to
specify the BoxSelect and LassoSelect selection tools with tools='box_select,lasso_select'.

Add a circle glyph to p1. The x-axis data is fertility and y-axis data is female literacy. Be sure to also specify source=source.

Create a second figure p2 similar to how you created p1.

Add a circle glyph to p2. The x-axis data is fertility and y-axis data is population. Be sure to also specify source=source.