Linked Behavior
With multidimensional data sets, interactive visualization can often enable someone to get a glimpse into how the data are related across multiple dimensions, beyond just the two dimensions that might make up a plot. One set of mechanisms supported by Bokeh involves linking behaviors exhibited in different but related plots. An example of this sort of linked brushing is illustrated below.
The code below and the plots that follow revisit the auto mpg data that we examined previously. Linked brushing in Bokeh is triggered by sharing data sources between different plots. By using some of the interactive plot tools to select and highlight a subset of points in one plot, we can see those same data points highlighted in another plot. In the code below, we load the autompg data into a ColumnDataSource
, and then use that CDS as the source of data for two plots that are arranged side-by-side (left
and right
). The plot on the left shows auto mpg vs. weight, and the plot on the right shows acceleration (accel) vs. horsepower (hp).
The code above, when run, produces interactive output in a file 'mpg_linked.html'. We have extracted the core of that html file and have inserted it into this page, resulting in an interactive pair of plots below. Each of the plots contains a set of icons on its right edge; if you hover your mouse pointer over an icon, the name of the tool is shown (Lasso Select, Box Select, Reset, Hover).
Choose one of the select buttons and then select a set of data points within one of the two plots. Box Select enables you to define a rectangular box that encompasses a set of points, and Lasso Select allows you to trace out a curve enclosing points. Whichever data points that are selected (enclosed) in one plot are highlighted, and the same data points are also highlighted in the neighboring plot.