添加一个下拉菜单以选择滤镜散景

时间:2018-09-02 15:35:27

标签: filter dropdown bokeh

我是python和bokeh中的新编码。 我有一个.csv文件,该文件的列具有两种因素(A和B)。我可以绘制带有A或B值的图表,但我想放置一个下拉菜单,从中可以选择因子(A或B)并更新绘图。

直到现在我有了:

import numpy as np
import pandas as pd
from bokeh.plotting import figure
from bokeh.charts import output_file, show
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Select
from bokeh.models.widgets import Div

df = pd.read_csv('/Users/Guilherme/Documents/Graficos/meusdados_3.csv', sep=';')

months = ['2017', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dez']
months2 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dez']

p1 = figure (x_range=meses, plot_height = 400, plot_width = 1100, title = "Plot")

p1.vbar(x=months, top=df[df.type=='b']['month'], width=0.9) #bar chart
p1.square(x=months2, y=df[df.type=='b']['summ'], line_width=2, color='orange') #square points
p1.line(x=months2, y=df[df.type=='b']['summ'], line_width=2, color='orange') #line between points
p1.line(x=months2, y=df[df.type=='b']['limit'],line_width=2, color='red', line_dash = "dotted") #limit line

#Title
title = Div(text='<h1 style="text-align: center">Dashboard</h1>', width=1100, height=100)

show(column(title, p1))

CSV print

0 个答案:

没有答案