I am trying the following code to produce 4 plots in two columns using the gridplot function.
from bokeh.plotting import figure
from bokeh.io import output_file, save, show
from bokeh.models import ColumnDataSource, Legend
from bokeh.layouts import gridplot, layout
outputfilename = r'c:\testing\test.html'
output_file(outputfilename)
n_plots = 4
x = [i for i in range(10)]
y = [i for i in range(10)]
df = {'x': x, 'y': y}
list_plots = []
source = ColumnDataSource(df)
TOOLS='hover,box_zoom,pan,xpan,ypan,wheel_zoom,reset,save,crosshair'
for i in range(n_plots):
p = figure(tools=TOOLS)
ts = p.line('x', 'y', source=source)
legend = Legend(items=[('test', [ts])], location="center")
legend.click_policy = 'hide'
p.add_layout(legend, 'right')
list_plots.append(p)
new_layout = []
for i in range(int(n_plots/2)):
new_layout.append([list_plots[i * 2 + 1], list_plots[i * 2]])
grid = gridplot(new_layout)
save(grid)
I have two issues with the code above:
- the toolbar does not show the xpan and the ypan
- there is only one toolbar. How can I show an individual toolbar for each plot using gridplot?
Thanks in advance
Giovanni