def add_visual_box_select(plot):
 source = ColumnDataSource(data=dict(x=[], y=[], width=[], height=[]))
 rect = Rect(x='x', y='y', width='width', height='height', fill_alpha=0.3, fill_color='#009933')
 callback = CustomJS(args=dict(source=source), code="\n        // get data source from Callback args\n        var data = source.data;\n\n        /// get BoxSelectTool dimensions from cb_data parameter of Callback\n        var geometry = cb_data['geometry'];\n\n        /// calculate Rect attributes\n        var width = geometry['x1'] - geometry['x0'];\n        var height = geometry['y1'] - geometry['y0'];\n        var x = geometry['x0'] + width/2;\n        var y = geometry['y0'] + height/2;\n\n        /// update data source with new Rect attributes\n        data['x'].push(x);\n        data['y'].push(y);\n        data['width'].push(width);\n        data['height'].push(height);\n\n        // trigger update of data source\n        source.trigger('change');\n    ")
 box_select = BoxSelectTool(callback=callback)
 plot.add_glyph(source, rect, selection_glyph=rect, nonselection_glyph=rect)
 plot.add_tools(box_select)
 return plot

def add_visual_box_select ( plot ) : source = ColumnDataSource ( data = dict ( x = [ ] , y = [ ] , width = [ ] , height = [ ] ) ) rect = Rect ( x = 'x' , y = 'y' , width = 'width' , height = 'height' , fill_alpha = 0.3 , fill_color = '#009933' ) callback = CustomJS ( args = dict ( source = source ) , code = "\n        // get data source from Callback args\n        var data = source.data;\n\n        /// get BoxSelectTool dimensions from cb_data parameter of Callback\n        var geometry = cb_data['geometry'];\n\n        /// calculate Rect attributes\n        var width = geometry['x1'] - geometry['x0'];\n        var height = geometry['y1'] - geometry['y0'];\n        var x = geometry['x0'] + width/2;\n        var y = geometry['y0'] + height/2;\n\n        /// update data source with new Rect attributes\n        data['x'].push(x);\n        data['y'].push(y);\n        data['width'].push(width);\n        data['height'].push(height);\n\n        // trigger update of data source\n        source.trigger('change');\n    " ) box_select = BoxSelectTool ( callback = callback ) plot . add_glyph ( source , rect , selection_glyph = rect , nonselection_glyph = rect ) plot . add_tools ( box_select ) return plot
add a box select tool to your plot which draws a rect on box select .