def plot3(): p = figure(title='something', x_axis_label='date', x_axis_type='datetime') df = pd.read_csv('chart.csv') df3 = pd.read_csv('df3d.csv') output_file("stacked_bar.html") p = Bar(df3, label='Country', values='Population wo access water', stack='category', color=color(columns='category', palette=['Orange', 'Red'], sort=False), legend='top_right') script, div = components(p) df4 = df[df['status'] == 'water supplier'] output_file("bar.html") q = Bar(df4, label='Country', values='Possible water provider', legend=False, color="Green") script2, div2 = components(q) return render_template('plot3.html', script=script, div=div, script2=script2, div2=div2)
def generate_chart(year): data = get_data(year) barchart = Bar(data, values=blend(*SCORED_EVENTS, labels_name='event'), label=cat(columns='Team', sort=False), stack=cat(columns='event', sort=False), color=color(columns='event', palette=Spectral9, sort=False), xgrid=False, ygrid=False, legend='top_right', plot_width=1000, plot_height=625, tools="pan,wheel_zoom,box_zoom,reset,resize") barchart.title = "Formula SAE Michigan " + str(year) + " Total Scores by Place" barchart._xaxis.axis_label = "Teams" barchart._xaxis.axis_line_color = None barchart._xaxis.major_tick_line_color = None barchart._xaxis.minor_tick_line_color = None barchart._xaxis.major_label_text_font_size = '0.6em' barchart._yaxis.axis_label = "Total Score" barchart._yaxis.axis_line_color = None barchart._yaxis.major_tick_line_color = None barchart._yaxis.minor_tick_line_color = None barchart.outline_line_color = None barchart.toolbar_location = 'right' barchart.logo = None return barchart
def generate_chart(team): data = generate_data(team) selectable_years = list(map(str, data.index.unique())) # Generate the chart UNFORTUNATELY using the high level plots. Streaming # a bunch of quads resulted in lots of graphics corruption when switching # teams. I would rather have the plots work all the time but really slow # then have the plot show the wrong information. barchart = Bar(data, values=blend(*SCORED_EVENTS, labels_name='event'), label=cat(columns='Year', sort=False), stack=cat(columns='event', sort=False), color=color(columns='event', palette=Spectral9, sort=False), xgrid=False, ygrid=False, plot_width=1000, plot_height=625, tools="pan,wheel_zoom,box_zoom,reset,resize") barchart.title = "Formula SAE Michigan - " + team barchart._xaxis.axis_label = "Teams" barchart._xaxis.axis_line_color = None barchart._xaxis.major_tick_line_color = None barchart._xaxis.minor_tick_line_color = None barchart._yaxis.axis_label = "Total Score" barchart._yaxis.axis_line_color = None barchart._yaxis.major_tick_line_color = None barchart._yaxis.minor_tick_line_color = None barchart.outline_line_color = None barchart.toolbar_location = 'right' barchart.logo = None # Hacky tooltips for renderer in barchart.select(GlyphRenderer): if renderer.data_source.data['height'] != [0]: year = renderer.data_source.data['Year'] place = data['Place'].loc[data['Year'] == year] score = data['Total Score'].loc[data['Year'] == year] hover = HoverTool(renderers=[renderer], tooltips=[("Year", '@Year'), ("Selection", '@event'), ("Event Score", '@height'), ("Total Score", '%.2f' % score.values[0]), ("Overall Place", '%d' % place.values[0])]) barchart.add_tools(hover) return barchart
def hitrun_chart(value, value_label, filename): ''' Takes 3 string arguments: column name of attribute being pivoted with HIT_RUN_FLAG as "value", an axis label name as "value_label", and a filename for the final JS output as "filename" Outputs Bokeh plot in JS format for embedding ''' df = pd.pivot_table(crashes[crashes.HIT_RUN_FLAG == 'Yes'], values='HIT_RUN_FLAG', index=value, aggfunc='count') df = df.to_frame() hitrun_speed.reset_index(inplace=True) hover = HoverTool(tooltips=[ ("Total hit and runs", "@height"), ]) tools = [hover] a = Bar(df, label=CatAttr(columns=[value], sort=False), values='HIT_RUN_FLAG', plot_width=720, plot_height=720, color=color(columns='HIT_RUN_FLAG', palette=palette), tools=tools, legend='top_right', sizing_mode="scale_both") a.xaxis.axis_label = value_label a.yaxis.axis_label = 'Total number of hit and runs' #save file to JS script, div = components(a) foo = open(filename, 'w') foo.write(script) foo.close
def generate_chart(): data = get_data() # Bokeh doesn't let me control the order of the grouping! This is # frustrating since it will be different on every server launch barchart = Bar(data, label='year', values='count', group=cat(columns='size', ascending=True, sort=True), color=color(columns='size', palette=Spectral4), legend='top_left', xgrid=False, ygrid=False, plot_width=800, plot_height=500, tools="pan,wheel_zoom,box_zoom,reset,resize") barchart.title = "Formula SAE Michigan Engine Cylinders" barchart._xaxis.axis_label = "Year" barchart._xaxis.axis_line_color = None barchart._xaxis.major_tick_line_color = None barchart._xaxis.minor_tick_line_color = None barchart._yaxis.axis_label = "Frequency" barchart._yaxis.axis_line_color = None barchart._yaxis.major_tick_line_color = None barchart._yaxis.minor_tick_line_color = None barchart.outline_line_color = None barchart.toolbar_location = 'right' barchart.logo = None hover = HoverTool(tooltips=[("Engine", '@size'), ("# Teams", '@height')]) barchart.add_tools(hover) return barchart
def stack_bokeh(infile): with open(infile, "r") as file: data = pd.read_csv(file) print(data) p = Bar(data, values=blend('locus dropout', 'allelic dropout', 'biallelic coverage', name='samp', labels_name="samps"), label=cat(columns='Sample', sort=False), stack=cat(columns='samps', sort=False), color=color(columns="samps", palette=["green", "red", "black"], sort=False), legend='top_right', title="sam") output_file("stacked_bar.html") curdoc().add_root(p) show(p)
def _create_plot(self): drought_years = self._drought_analysis.label_years() merged = self._annual_data.to_frame(name="Annual").merge( drought_years.to_frame(name="InDrought"), how='left', left_index=True, right_index=True) # Choose a color palette that sets drought years to red and non drought # years to green. drought_color = color(columns="InDrought", palette=["green", "red"]) return Bar( data=merged, label="index", values="Annual", color=drought_color, agg='sum', #FIXME: The label doesn't display in the legend correctly #legend="top_right", xlabel="Year", **self._plotargs)
def plot_read_dist(rinfo): df = pd.read_table(rinfo) data = df[['length', 'mapper', 'count']].groupby(['length', 'mapper']).count() data = data.apply(lambda s: s / data.sum() * 100, axis=1).reset_index() p = Bar(data, plot_width=500, plot_height=400, label='length', values='count', agg='sum', stack=cat(columns='mapper', sort=False), legend='top_right', color=color(columns='mapper', palette=["#f98283", "#a4a4a4"], sort=False), xlabel='read length (nt)', ylabel='proportion (%)', ygrid=False, tooltips=[('length', '@length'), ('mapper', '@mapper'), ('percent', '@height')]) p.toolbar.logo = None p.outline_line_color = None return p
def generate_chart(year): data = get_data(year) barchart = Bar(data, values=blend(*SCORED_EVENTS, labels_name='event'), label=cat(columns='Team', sort=False), stack=cat(columns='event', sort=False), color=color(columns='event', palette=Spectral9, sort=False), xgrid=False, ygrid=False, legend='top_right', plot_width=1000, plot_height=625, tools="pan,wheel_zoom,box_zoom,reset,resize") barchart.title = "Formula SAE Michigan " + str( year) + " Total Scores by Place" barchart._xaxis.axis_label = "Teams" barchart._xaxis.axis_line_color = None barchart._xaxis.major_tick_line_color = None barchart._xaxis.minor_tick_line_color = None barchart._xaxis.major_label_text_font_size = '0.6em' barchart._yaxis.axis_label = "Total Score" barchart._yaxis.axis_line_color = None barchart._yaxis.major_tick_line_color = None barchart._yaxis.minor_tick_line_color = None barchart.outline_line_color = None barchart.toolbar_location = 'right' barchart.logo = None return barchart
from bokeh.charts import Bar, output_file, show from bokeh.charts.operations import blend from bokeh.charts.attributes import cat, color from bokeh.charts.utils import df_from_json from bokeh.sampledata.olympics2014 import data # utilize utility to make it easy to get json/dict data converted to a dataframe df = df_from_json(data) # filter by countries with at least one medal and sort by total medals df = df[df['total'] > 0] df = df.sort("total", ascending=False) bar = Bar(df, values=blend('bronze', 'silver', 'gold', name='medals', labels_name='medal'), label=cat(columns='abbr', sort=False), stack=cat(columns='medal', sort=False), color=color(columns='medal', palette=['SaddleBrown', 'Silver', 'Goldenrod'], sort=False), legend='top_right', title="Medals per Country, Sorted by Total Medals", tooltips=[('medal', '@medal'), ('country', '@abbr')]) output_file("stacked_bar.html") show(bar)
def output_components(prefix, order, maxaln): rinfo = "{0}.rinfo".format(prefix) comp = "{0}.comp".format(prefix) def plot_read_dist(rinfo): df = pd.read_table(rinfo) data = df[['length', 'mapper', 'count']].groupby(['length', 'mapper']).count() data = data.apply(lambda s: s / data.sum() * 100, axis=1).reset_index() p = Bar(data, plot_width=500, plot_height=400, label='length', values='count', agg='sum', stack=cat(columns='mapper', sort=False), legend='top_right', color=color(columns='mapper', palette=["#f98283", "#a4a4a4"], sort=False), xlabel='read length (nt)', ylabel='proportion (%)', ygrid=False, tooltips=[('length', '@length'), ('mapper', '@mapper'), ('percent', '@height')]) p.toolbar.logo = None p.outline_line_color = None return p rdist = plot_read_dist(rinfo) df = pd.read_table(comp, index_col=0) total = df.sum() total = total * 100 / total.sum() df = df.apply(lambda s: s * 100 / s.sum(), axis=1) df = df.reset_index() #ftypes = df.columns[1:].tolist() ftypes = order colors = sns.color_palette("hls", len(ftypes)).as_hex() bar = Bar(df, values=blend(*ftypes, name="ftypes", labels_name="ftype"), x_range=rdist.x_range, y_range=(0, 100), label=cat(columns='rlen', sort=False), stack=cat(columns='ftype', sort=False), xlabel='read length (nt)', ylabel='proportion (%)', legend="top_right", ygrid=False, width=500, height=400, color=color(columns='ftype', palette=colors, sort=False), fill_alpha=1, tooltips=[("length", "@rlen"), ("feature", "@ftype"), ("percent", "@height")]) bar.toolbar.logo = None bar.outline_line_color = None start_angles = {} end_angles = {} start = 0 for ftype in ftypes: end = 2 * pi * total[ftype] / 100 start_angles[ftype] = start end_angles[ftype] = start + end start += end colors = dict(zip(ftypes, colors)) df = pd.DataFrame(total).reset_index() df.columns = ["ftype", "percent"] df["start"] = df.apply(lambda s: start_angles[s["ftype"]], axis=1) df["end"] = df.apply(lambda s: end_angles[s["ftype"]], axis=1) df["color"] = df.apply(lambda s: colors[s["ftype"]], axis=1) df["x"] = df.apply(lambda s: 1.2 * cos( (start_angles[s["ftype"]] + end_angles[s["ftype"]]) / 2), axis=1) df["y"] = df.apply(lambda s: 1.2 * sin( (start_angles[s["ftype"]] + end_angles[s["ftype"]]) / 2), axis=1) df["text"] = df.apply(lambda s: "{0:.3f}%".format(s["percent"]), axis=1) source = ColumnDataSource(data=df) pie = figure(width=400, height=400, x_range=(-1.4, 1.4), y_range=(-1.4, 1.4)) pie.toolbar.logo = None wr = pie.annular_wedge(x=0, y=0, inner_radius=0.5, outer_radius=1, start_angle="start", end_angle="end", fill_color="color", line_color="#ffffff", line_width=0.5, source=source) pie.axis.visible = False pie.grid.grid_line_color = None pie.outline_line_color = None hover = HoverTool(tooltips=[("feature", "@ftype"), ("percent", "@percent")], renderers=[wr]) pie.add_tools(hover) text_props = { "source": source, "angle": 0, "color": "black", "text_align": "center", "text_baseline": "middle", "text_font_size": "8pt", "text_font_style": "normal" } pie.text(x="x", y="y", text="text", **text_props) empty = figure(width=400, height=400, x_range=(-1.1, 1.1), y_range=(-1.1, 1.1)) empty.toolbar.logo = None empty.axis.visible = False empty.grid.grid_line_color = None empty.outline_line_color = None empty.toolbar_location = None stat = get_stat(prefix, maxaln) source = ColumnDataSource(data=stat) columns = [ TableColumn(field="Statistics", title="Statistics", width=200), TableColumn(field="Number of reads", title="Number of reads", formatter=NumberFormatter(format="0,0"), width=150), TableColumn(field="Proportion", title="Proportion", formatter=NumberFormatter(format="0.000%"), width=100), ] data_table = DataTable(source=source, columns=columns, width=450, row_headers=False) script, div = components( layout([[data_table, rdist], [pie, bar]], sizing_mode="scale_width")) return script, div
from bokeh.charts import Bar, output_file, show from bokeh.charts.attributes import cat, color from bokeh.charts.operations import blend from bokeh.charts.utils import df_from_json from bokeh.sampledata.olympics2014 import data # utilize utility to make it easy to get json/dict data converted to a dataframe df = df_from_json(data) # filter by countries with at least one medal and sort by total medals df = df[df['total'] > 0] df = df.sort_values(by="total", ascending=False) bar = Bar(df, values=blend('bronze', 'silver', 'gold', name='medals', labels_name='medal'), label=cat(columns='abbr', sort=False), stack=cat(columns='medal', sort=False), color=color(columns='medal', palette=['SaddleBrown', 'Silver', 'Goldenrod'], sort=False), legend='top_right', title="Medals per Country, Sorted by Total Medals", tooltips=[('medal', '@medal'), ('country', '@abbr')]) output_file("stacked_bar.html", title="stacked_bar.py example") show(bar)
from bokeh.charts import Bar, output_file, show from bokeh.charts.attributes import cat, color from bokeh.charts.operations import blend from bokeh.charts.utils import df_from_json from bokeh.sampledata.olympics2014 import data # utilize utility to make it easy to get json/dict data converted to a dataframe df = df_from_json(data) # filter by countries with at least one medal and sort by total medals df = df[df["total"] > 0] df = df.sort("total", ascending=False) bar = Bar( df, values=blend("bronze", "silver", "gold", name="medals", labels_name="medal"), label=cat(columns="abbr", sort=False), stack=cat(columns="medal", sort=False), color=color(columns="medal", palette=["SaddleBrown", "Silver", "Goldenrod"], sort=False), legend="top_right", title="Medals per Country, Sorted by Total Medals", tooltips=[("medal", "@medal"), ("country", "@abbr")], ) output_file("stacked_bar.html") show(bar)
def comparison(request, stock_id1, stock_id2): stock1 = get_object_or_404(Stock, pk=stock_id1) stock2 = get_object_or_404(Stock, pk=stock_id2) #update(stock1) #update(stock2) # Graph # Last known weekday current_day = weekday().isoformat() # Retrieve live data YYYY-MM-DD historical_price1 = ystockquote.get_historical_prices(stock1, '2013-01-24', current_day) correct_order1 = sorted(historical_price1) stock_prices1 = [] dates1 = [] for values in correct_order1: stock_prices1.append(historical_price1[values]['Adj Close']) dates1.append(values) # Convert to Float for p in range(len(stock_prices1)): stock_prices1[p] = float(stock_prices1[p]) # Convert to Datetime Format dates_objects1 = [] for d in dates1: dates_objects1.append(datetime.strptime(d, '%Y-%m-%d')) # Retrieve live data YYYY-MM-DD historical_price2 = ystockquote.get_historical_prices(stock2, '2013-01-24', current_day) correct_order2 = sorted(historical_price2) stock_prices2 = [] dates2 = [] for values in correct_order2: stock_prices2.append(historical_price2[values]['Adj Close']) dates2.append(values) # Convert to Float for p in range(len(stock_prices2)): stock_prices2[p] = float(stock_prices2[p]) # Convert to Datetime Format dates_objects2 = [] for d in dates2: dates_objects2.append(datetime.strptime(d, '%Y-%m-%d')) #Tools hover = HoverTool(mode='vline') crosshair = CrosshairTool(dimensions=['height']) TOOLS = [BoxZoomTool(), crosshair, PreviewSaveTool(), ResetTool()] p1 = figure(x_axis_type="datetime", responsive=True, plot_height=250,tools=TOOLS) p1.border_fill = "whitesmoke" # Multiple Axises min1 = min(stock_prices1) max1 = max(stock_prices1) min2 = min(stock_prices2) max2 = max(stock_prices2) p1.y_range = Range1d(start= min1- (min1/10),end=max1+ (min1/10)) p1.extra_y_ranges = {'range2':Range1d(start= min2- (min2/10),end=max2+ (min2/10))} p1.add_layout(LinearAxis(y_range_name="range2"), 'right') p1.line(np.array(dates_objects1, dtype=np.datetime64), stock_prices1, color='#b41f2e', legend=stock1.ticker) p1.line(np.array(dates_objects2, dtype=np.datetime64), stock_prices2, y_range_name='range2', color='#1F78B4', legend=stock2.ticker) p1.grid.grid_line_alpha = 0.3 p1.xaxis.axis_label = 'Date' p1.yaxis.axis_label = 'Price' script, div = components(p1) # Bar Charts mc1 = float((stock1.market_cap[:-1])) mc2 = float((stock2.market_cap[:-1])) pe1 = float(stock1.pe_ratio) pe2 = float(stock2.pe_ratio) pb1 =float(stock1.pb_ratio) pb2 = float(stock2.pb_ratio) vol1 = float(stock1.volume) vol2 = float(stock2.volume) rev1 = float((stock1.revenue[:-1])) rev2 = float((stock2.revenue[:-1])) peg1 = float(stock1.peg) peg2 = float(stock2.peg) mc_dict= {'tickers':[stock1.ticker,stock2.ticker], 'market cap':[mc1,mc2], 'PB Ratio':[pb1,pb2], 'PE Ratio':[pe1,pe2], 'Volume': [vol1,vol2], 'Revenue': [rev1,rev2], 'PE Growth': [peg1,peg2] } #Hover Tools - Not working #hover_mc = HoverTool(tooltips=[('Market Cap', '@height'), ('Ticker', '@cat'), ]) mc_bar = Bar(mc_dict,width=250, height=250,values='market cap',label='tickers', color=color(columns='market cap',palette=['#b41f2e','#1F78B4']), title="Market Cap", ylabel='Billions') vol_bar = Bar(mc_dict, width=250, height=250,values='Volume', label='tickers', color=color(columns='Volume',palette=['#b41f2e','#1F78B4']), title="Volume",ylabel='Volume') pb_bar = Bar(mc_dict, width=250, height=250,values='PB Ratio', label='tickers', color=color(columns='PB Ratio',palette=['#b41f2e','#1F78B4']),title="PB Ratio",ylabel='Ratio') pe_bar = Bar(mc_dict, width=250, height=250,values='PE Ratio', label='tickers', color=color(columns='PE Ratio',palette=['#b41f2e','#1F78B4']), title="PE Ratio",ylabel='Ratio') peg_bar = Bar(mc_dict, width=250, height=250, values='PE Growth', label='tickers', color=color(columns='PE Growth', palette=['#b41f2e', '#1F78B4']), title="PE Growth", ylabel='Percentage(%)') rev_bar = Bar(mc_dict, width=250, height=250, values='Revenue', label='tickers', color=color(columns='Revenue', palette=['#b41f2e', '#1F78B4']), title="Revenue", ylabel='Billions') mc_bar.border_fill_color = "whitesmoke" vol_bar.border_fill_color = "whitesmoke" pb_bar.border_fill_color = "whitesmoke" pe_bar.border_fill_color = "whitesmoke" peg_bar.border_fill_color = "whitesmoke" rev_bar.border_fill_color = "whitesmoke" grid = gridplot([[mc_bar,rev_bar, pe_bar],[vol_bar, pb_bar, peg_bar]]) mscript, mdiv = components(grid) context = {'stock1': stock1, 'stock2': stock2, 'the_script': script, 'the_div': div, 'mc1': mscript, 'mc2': mdiv, } return render(request, 'stocktracker/comparison.html', context)
def portalDynamicity(df): def getWeekString(yearweek): if yearweek is None or len(str(yearweek)) == 0: return '' year = "'" + str(yearweek)[:2] week = int(str(yearweek)[2:]) # d = d - timedelta(d.weekday()) # dd=(week)*7 # dlt = timedelta(days = dd) # first= d + dlt # dlt = timedelta(days = (week)*7) # last= d + dlt + timedelta(days=6) return 'W' + str(week) + '-' + str(year) bp = figure(plot_width=600, plot_height=300, y_axis_type="datetime", responsive=True, tools='') # ,toolbar_location=None bp.toolbar.logo = None bp.toolbar_location = None label_dict={} for i, s in enumerate(df['snapshot']): label_dict[i] = getWeekString1(s) bp.yaxis[0].formatter = NumeralTickFormatter(format="0.0%") bp.xaxis[0].axis_label = 'Snapshots' bp.yaxis[0].axis_label = '% of portals' li = bp.line(df.index.values.tolist(), df['dyratio'], line_width=2, line_color='red', legend="dyratio") c = bp.circle(df.index.values.tolist(), df['dyratio'], line_width=2, line_color='red', legend="dyratio") li1 = bp.line(df.index.values.tolist(), df['adddelratio'], line_width=2, line_color='blue', legend="adddelratio") c = bp.circle(df.index.values.tolist(), df['adddelratio'], line_width=2, line_color='blue', legend="adddelratio") legend = bp.legend[0].legends bp.legend[0].legends = [] l = Legend(location=(0, -30)) l.items = legend bp.add_layout(l, 'right') labels=["staticRatio","updatedRatio","addRatio","delRatio"] #for l in labels: # df[l]= df[l]*100 print brewer.keys() colors = brewer["Pastel2"][len(labels)] bar = Bar(df, values=blend("staticRatio","updatedRatio","addRatio","delRatio", name='medals', labels_name='medal'), label=cat(columns='snapshot', sort=False), stack=cat(columns='medal', sort=False), color=color(columns='medal', palette=colors, sort=False), legend='top_right', bar_width=0.5, responsive=True, tooltips=[('ratio', '@medal'), ('snapshot', '@snapshot'),('Value of Total',' @height{0.00%}')]) legend = bar.legend[0].legends bar.legend[0].legends = [] l = Legend(location=(0, -30)) l.items = legend bar.add_layout(l, 'right') bar.xaxis[0].axis_label = 'Snapshots' bar.yaxis[0].axis_label = '% of datasets' bar.width=600 bar.height=300 bar.xaxis[0].formatter = FuncTickFormatter.from_py_func(getWeekStringTick) bar.toolbar.logo = None bar.toolbar_location = None bar.yaxis[0].formatter = NumeralTickFormatter(format="0.0%") return {'bar':bar,'lines':bp}
ts.resample('M').mean().to_frame(name="mean"), left_index=True, right_index=True) frame = pd.merge(firstmerge, ts.resample('M').max().to_frame(name="max"), left_index=True, right_index=True) # You can use DataFrame index for bokeh x values but it doesn't like timestamp frame['Month'] = frame.index.strftime('%m-%Y') # Main object to render with stacking bar = Bar(frame, values=blend('min', 'mean', 'max', name='values', labels_name='stats'), label=cat(columns='Month', sort=False), stack=cat(columns='values', sort=False), color=color(columns='values', palette=['SaddleBrown', 'Silver', 'Goldenrod'], sort=True), legend=None, title="Statistical Values Grouped by Month", tooltips=[('Value', '@values')] ) # Legend info (if legend attribute is used it gets ugly with large dataset) factors = ["min", "mean", "max"] x = [0] * len(factors) y = factors pal = ['SaddleBrown', 'Silver', 'Goldenrod'] p = figure(width=100, toolbar_location=None, y_range=factors) p.rect(x, y, color=pal, width=10, height=1) p.xaxis.major_label_text_color = None p.xaxis.major_tick_line_color = None
data['Date'].append(unique_dates[m]) data['Total'] = [ data['ACCEPTABLE'][k] + data['UNACCEPTABLE'][k] for k in range(len(data['Date'])) ] df = pd.DataFrame(data) bar = Bar(df, values=blend('ACCEPTABLE', 'UNACCEPTABLE', name='Hours', labels_name='medal'), label=cat(columns='Date', sort=False), stack=cat(columns='medal', sort=False), color=color(columns='medal', palette=['Green', 'Red'], sort=False), legend='top_left', title="Respiration data quality of participant id " + str(ids[i]), width=800) output_file('Respiration_DataQuality_of_' + str(ids[i]) + ".html", title="RIP_BAR_Plot") source = ColumnDataSource(data) columns = [ TableColumn(field="Date", title="Date"), TableColumn(field="ACCEPTABLE", title="ACCEPTABLE(Hours)"), TableColumn(field="UNACCEPTABLE", title="UNACCEPTABLE(Hours)"),