import numpy as np import random from bokeh.models.tools import BoxZoomTool, ResetTool, PanTool from bokeh.models import NumeralTickFormatter, HoverTool from bokeh.io import curdoc, show from bokeh.plotting import figure, show from bokeh.palettes import Turbo256 from bokeh.transform import linear_cmap from bokeh.layouts import row x = [1, 2, 3, 4, 5] y1 = [6, 7, 2, 4, 5] y2 = [2, 3, 4, 5, 6] y3 = [4, 5, 5, 7, 2] p = figure(title="Multiple line example",\ # y_range=(0,25),\ sizing_mode = "stretch_width",\ height = 550,\ y_axis_type = "log",\ y_range = [0.001, 10**3],\ x_axis_label='x',\ y_axis_label='y',\ tools = [BoxZoomTool(), ResetTool(), HoverTool()],\ tooltips = "Data point @x has the value @y") p.line(x, y1, legend_label="Temp.", color="blue", line_width=2) p.vbar(x=x, top=y2, legend_label="Rate", color="red", width=0.5, bottom=0) circle = p.circle(x, y3, legend_label="Objects",\ fill_color="green", fill_alpha=0.5,\ line_color="lightgreen", size=30) #change plot properties glyph = circle.glyph glyph.line_color = "green" glyph.fill_color = "lightgreen" #customize legend p.legend.location = "top_center" p.legend.title = "Observations" p.legend.label_text_font = "times" p.legend.label_text_font_style = "italic" p.legend.label_text_color = "navy" p.legend.border_line_width = 3 p.legend.border_line_color = "navy" p.legend.border_line_alpha = 0.8 p.legend.background_fill_color = "navy" p.legend.background_fill_alpha = 0.2 #change axes properties p.xaxis.axis_label = "Temp" p.xaxis.axis_line_width = 3 p.xaxis.axis_line_color = "red" p.yaxis.axis_label = "Pressure" p.yaxis.major_label_text_color = "orange" p.yaxis.major_label_orientation = "vertical" p.axis.minor_tick_in = 0 p.axis.minor_tick_out = -5 #Grid lines p.xgrid.grid_line_color = "olive" p.xgrid.grid_line_alpha = 0.1 p.xgrid.grid_line_dash = [3,3] p.ygrid.grid_line_alpha = 0.8 p.ygrid.grid_line_dash = [6, 4] #grid bands p.ygrid.band_fill_color = "olive" p.ygrid.band_fill_alpha = 0.1 p.xgrid.bounds = (2, 4) #background colors p.background_fill_color = "lightgrey" p.border_fill_color = "olive" p.border_fill_alpha = 0.2 #Tick Formatter objects #p.yaxis[0].formatter = NumeralTickFormatter(format="$0.00") #Toolbar p.toolbar_location = "below" p.toolbar.autohide = True p.toolbar.logo = None p.add_tools(PanTool(dimensions="width")) #show(p) y = [4, 5, 5, 7, 2] curdoc().theme = "dark_minimal" q = figure(sizing_mode = "stretch_width", max_width= 500, height = 250) q.line(x, y) #show(q) #x = list(range(0,26)) #y = random.sample(range(0,100), 26) N = 1000 x = np.random.random(size=N) *100 y = np.random.random(size=N) * 100 mapper = linear_cmap(field_name="y", palette=Turbo256, low=min(y), high=max(y)) radii = y / 100*2 colors = ["#%02x%02x%02x" % (255, int(round(value * 255 / 100)), 255) for value in y] q = figure(title="Vectorized colors example",\ sizing_mode = "stretch_width",\ max_width=500,\ height=250) #line = q.line(x,y, line_color="lightgrey", line_width=1) circle = q.circle(x, y, radius=radii, fill_color=mapper, line_color="lightgrey", size=15) show(row(children=[p,q], sizing_mode="scale_width"))