def HLevelLine(): # sample = pd.read_table('http://kelesidis.de/static/data/sample.txt') # Use the Sample Data # Make a list with the months ys = [month for month in sample.columns[1:]] TOOLS = 'pan,wheel_zoom,hover,crosshair,resize,reset' TOOLTIPS = [("Year", "$~x"), ("Temp", "$y")] # make our line configurations # import from df, x= the Year column, y = the ys list we created above p = Line(sample, x = 'Year', y = ys, title = "Hight Level Bokeh Line Chart", legend = "bottom_left", ylabel = 'Temp', tools = TOOLS, width = 600, height = 450, responsive = True) # hover tool configuration p_hover = p.select(HoverTool) p_hover.tooltips = TOOLTIPS p.logo = None return p
svalues[k] = [(i, v) for i, v in zip(index, xyvalues[k])] # # import pdb; pdb.set_trace() scatter_point = Scatter(svalues, title="Scatter mouse", ylabel='measures', width=500, height=300, legend=True, tools=TOOLS) scatter = Scatter(svalues, title="Scatter V Line", ylabel='measures', width=500, height=300, legend=True, tools=TOOLS) int_point_line = Line(xyvalues, title="Lines Mouse Interp.", ylabel='measures', width=500, height=300, tools=TOOLS) point_line = Line(xyvalues, title="Lines Mouse", ylabel='measures', width=500, height=300, tools=TOOLS) hhover = hline.select(dict(type=HoverTool)) hhover.mode = 'hline' hhover.line_policy = 'next' vhover = vline.select(dict(type=HoverTool)) vhover.mode = 'vline' vhover.line_policy = 'nearest' int_hhover = int_hline.select(dict(type=HoverTool)) int_hhover.mode = 'hline' int_hhover.line_policy = 'interp' int_vhover = int_vline.select(dict(type=HoverTool)) int_vhover.mode = 'vline' int_vhover.line_policy = 'interp'
import time import numpy as np from bokeh.charts import Line, curdoc, cursession, output_server, show from bokeh.models import GlyphRenderer N = 80 x = np.linspace(0, 4*np.pi, N) xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x)) output_server("line_animate") chart = Line(xyvalues, title="Lines", ylabel='measures') curdoc().add(chart) show(chart) renderer = chart.select(dict(type=GlyphRenderer)) ds = renderer[0].data_source while True: for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))): for k, values in xyvalues.items(): if k != 'x': ds.data['y_%s'%k] = values * i cursession().store_objects(ds) time.sleep(0.05)
scatter_point = Scatter(data, x='Year', y='Count', color='Degree', title="Scatter mouse", ylabel='measures', legend=True, tools=TOOLS) scatter = Scatter(data, x='Year', y='Count', color='Degree', title="Scatter V Line", ylabel='measures', legend=True, tools=TOOLS) int_point_line = Line(data, x='Year', y='Count', color='Degree', title="Lines Mouse Interp.", ylabel='measures', tools=TOOLS) point_line = Line(data, x='Year', y='Count', color='Degree', title="Lines Mouse", ylabel='measures', tools=TOOLS) hhover = hline.select(HoverTool) hhover.mode = 'hline' hhover.line_policy = 'next' vhover = vline.select(HoverTool) vhover.mode = 'vline' vhover.line_policy = 'nearest' int_hhover = int_hline.select(HoverTool) int_hhover.mode = 'hline' int_hhover.line_policy = 'interp' int_vhover = int_vline.select(HoverTool) int_vhover.mode = 'vline' int_vhover.line_policy = 'interp'
x='Year', y='Count', color='Degree', title="Lines Mouse Interp.", ylabel='measures', tools=TOOLS) point_line = Line(data, x='Year', y='Count', color='Degree', title="Lines Mouse", ylabel='measures', tools=TOOLS) hhover = hline.select(HoverTool) hhover.mode = 'hline' hhover.line_policy = 'next' vhover = vline.select(HoverTool) vhover.mode = 'vline' vhover.line_policy = 'nearest' int_hhover = int_hline.select(HoverTool) int_hhover.mode = 'hline' int_hhover.line_policy = 'interp' int_vhover = int_vline.select(HoverTool) int_vhover.mode = 'vline' int_vhover.line_policy = 'interp'
tools=TOOLS) int_point_line = Line(xyvalues, title="Lines Mouse Interp.", ylabel='measures', width=500, height=300, tools=TOOLS) point_line = Line(xyvalues, title="Lines Mouse", ylabel='measures', width=500, height=300, tools=TOOLS) hhover = hline.select(dict(type=HoverTool)) hhover.mode = 'hline' hhover.line_policy = 'next' vhover = vline.select(dict(type=HoverTool)) vhover.mode = 'vline' vhover.line_policy = 'nearest' int_hhover = int_hline.select(dict(type=HoverTool)) int_hhover.mode = 'hline' int_hhover.line_policy = 'interp' int_vhover = int_vline.select(dict(type=HoverTool)) int_vhover.mode = 'vline' int_vhover.line_policy = 'interp'
import numpy as np from bokeh.plotting import * from bokeh.charts import Line from bokeh.models import GlyphRenderer N = 80 x = np.linspace(0, 4 * np.pi, N) output_server("line_animate") xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x)) chart = Line(xyvalues, title="Lines", ylabel='measures') curdoc().add(chart) show(chart) _session = cursession() # it's also possible to use the following with the server='line_animate' arg on chart # chart.show() # _session = chart.session renderer = chart.select(dict(type=GlyphRenderer)) ds = renderer[0].data_source while True: for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))): for k, values in xyvalues.items(): if k != 'x': ds.data['y_%s' % k] = values * i _session.store_objects(ds) time.sleep(0.05)