У меня проблемы с "Боке".Я создаю 3 различных графика и инструмент виджета независимо друг от друга.Мне нужно сделать их интерактивными: получить график p4, нажав 2018/09/14, получить p5, нажав 2018/09/15, и p6, нажав 2018/09 / 16.
import pandas as pd
import numpy as np
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Select
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.layouts import row
from random import random
from bokeh.plotting import figure, curdoc
from bokeh.io import output_file, show, output_notebook
edges = np.array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 ,
0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85,
0.9 , 0.95, 1. ])
arr_hist = np.array([22, 8, 0, 1, 3, 4, 5, 3, 8, 7, 10, 12, 9, 3, 3, 7, 0,
0, 3, 3])
arr_hist2 = np.array([69, 3, 2, 4, 8, 3, 2, 1, 1, 4, 1, 3, 2, 2, 4, 1, 0,
1, 0, 0])
arr_hist3 = np.array([71, 10, 4, 2, 4, 2, 2, 0, 4, 1, 2, 0, 1, 0, 6, 2, 0,
0, 0, 0])
a = {'distr': [arr_hist, arr_hist2, arr_hist3],'left': [edges[:-1], edges[:-1], edges[:-1]], 'right': [edges[1:], edges[1:], edges[1:]]}
a1=pd.DataFrame(data=a)
a2=a1.T
a2.columns=['2018/09/14','2018/09/15','2018/09/16']
####### p4 #########
p4 = figure(plot_height = 600, plot_width = 600,
title = 'Histogram 2018/09/14',
x_axis_label = 'Occupancy (%)',y_axis_label = 'Counts')
p4.quad(bottom=0, top=a2['2018/09/14'][0],
left=a2['2018/09/14'][1], right=a2['2018/09/14'][2],
fill_color='red', line_color='black')
####### p5 #########
p5 = figure(plot_height = 600, plot_width = 600,
title = 'Histogram 2018/09/15',
x_axis_label = 'Occupancy (%)',y_axis_label = 'Counts')
p5.quad(bottom=0, top=a2['2018/09/15'][0],
left=a2['2018/09/15'][1], right=a2['2018/09/15'][2],
fill_color='red', line_color='black')
#output_notebook()
####### p6 #########
p6 = figure(plot_height = 600, plot_width = 600,
title = 'Histogram 2018/09/16',
x_axis_label = 'Occupancy (%)',y_axis_label = 'Counts')
p6.quad(bottom=0, top=a2['2018/09/16'][0],
left=a2['2018/09/16'][1], right=a2['2018/09/16'][2],
fill_color='red', line_color='black')
#output_notebook()
dates = Select(title="Dates:", value="foo", options=[a2[a2.columns[0]].name,a2[a2.columns[1]].name,a2[a2.columns[2]].name])
show(row(widgetbox(dates, width=300), p4, p5, p6))
output_file("Histograms.html")