具有堆叠图表的链接下拉菜单

时间:2019-10-17 07:04:39

标签: python bokeh

我有一个数据框,其中包含Yearmonth值,Brand TRx,Total TRx,Market   TRx,品牌NRx,总NRx和市场NRx数据。我正在尝试创建一个    TRx和NRx的堆栈图。并为用户提供从下拉菜单中选择TRx或NRx的选项

grouped = data.groupby('new_month')['Total_TRx', 'Market_TRx',"Brand_TRx"].sum()
source = ColumnDataSource(grouped)
months = source.data['new_month'].tolist()


p = figure(x_range=new_month)

p.vbar_stack(stackers=['Total_TRx', 'Market_TRx',"Brand_TRx"],
             x='new_month', source=source,
             legend = ['Total TRx','Market TRx','Calls'],
             width=0.5, color=Spectral3)

p.title.text ='TRx/NRx'
p.legend.location = 'top_left'

p.xaxis.axis_label = 'Rx Type'
p.xgrid.grid_line_color = None  #remove the x grid lines

p.yaxis.axis_label = 'Time Frame'

show(p)

suite_dropdown = Dropdown(label="Select", button_type="warning", menu=['TRx','NRx'])


show(widgetbox(children = [suite_dropdown], sizing_mode = "fixed"))

如何获取TRx和NRx的两个堆栈图,并通过下拉列表链接它们?

0 个答案:

没有答案