I'm working with four sets of data, each of them have several number of time series. i'm using bokeh for plotting all of them together, the result looks like this:
multiline graph bokeh with widget
from bokeh.plotting import figure, output_file, show
from bokeh.palettes import RdYlGn4
from bokeh.models import CustomJS, ColumnDataSource, MultiSelect
from bokeh.layouts import row, widgetbox
output_file("graph.html")
p = figure(plot_width=1000, plot_height=400, x_axis_type="datetime", title="title")
cdn = range(4)
for i,comp in enumerate(cdn):
ts=[t for t in data_plu_price.columns if int(t) in df.T[df.C==comp].values]
n_lines=len(data[ts].columns)
p.multi_line(xs=[data[ts].index.values]*n_lines, ys=[data[t].values for t in ts],line_color=RdYlGn4[i], legend=str(i))
p.title.align = "center"
p.title.text_font_size = "20px"
p.xaxis.axis_label = 'date'
p.yaxis.axis_label = 'val'
callback = CustomJS("""Some Code""")
multi_select = MultiSelect(title="Select:", value=cdn,
options=[(str(i), str(i)) for i in range(4)])
layout = row(p,widgetbox(multi_select))
show(layout)
The problem is it looks really messy, so I wanted to use the multiselect widget to show/hide all the groups of multilines(4). how to use the multiselect widget with a multi_line
plot?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…