Supports panning of the plot (like panning with a movie camera); i.e., moving the
plot (including x and y coordinates) relative to the fixed plotting frame
wheel_zoom
Enables zooming into the plot by using the mouse wheel
box_zoom
Enables zooming into the plot by marking a box with the mouse
reset
Resets the original/default view of the plot
previewsave
Generates a static (bitmap) version of the plot that can be saved in PNG format
The following code demonstrates adding these tools:
In [ 50 ]: bp.output_file(“../images/msft_2.html”,
title=“Bokeh Example (Interactive)”)
bp.line(
data[‘Date’],
data[‘Close’],
color=‘#0066cc’,
legend=‘MSFT’,
title=‘Historical Stock Quotes’,
x_axis_type = “datetime”,
tools = ‘pan, wheel_zoom, box_zoom, reset, previewsave’
# adding a list of interactive tools
)
bp.show()
The output of this code is shown as Figure 14-3, where the panning function is used to
move the plot within the plotting frame (compare this with Figure 14-2).
In principle, all the features shown so far can also be implemented by using matplotlib.
In fact, the interactive tools shown for Bokeh are available by default with matplotlib
when you plot into a separate window. Figure 14-4 shows a zoomed and panned version of
the pandas plot in Figure 14-1 in a separate (Python-controlled) window. However, in
contrast to Bokeh, matplotlib cannot “export” this functionality to be included in a
separate, standalone graphics file.
[ 55 ]