Python bokeh.plotting.curdoc() Examples
The following are 6
code examples of bokeh.plotting.curdoc().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh.plotting
, or try the search function
.
Example #1
Source File: bokeh.py From thingflow-python with Apache License 2.0 | 6 votes |
def run(self): print("In thread.run") self.p = figure(plot_height=500, tools=TOOLS, y_axis_location='left', title=self.title) self.p.x_range.follow = "end" self.p.xaxis.axis_label = "Timestamp" self.p.x_range.follow_interval = 100 self.p.x_range.range_padding = 0 self.p.line(x="timestamp", y="value", color="blue", source=self.source) self.p.circle(x="timestamp", y="value", color="red", source=self.source) self.session = push_session(curdoc()) curdoc().add_periodic_callback(self.update, 100) #period in ms self.session.show(column(self.p)) curdoc().title = 'Sensor' self.session.loop_until_closed() # def register(self, d, sourceq): # source = ColumnDataSource(dict(d)) # self.p.line(x=d[0], y=d[1], color="orange", source=source) # curdoc().add_periodic_callback(self.update, 100) #period in ms
Example #2
Source File: view.py From osspolice with GNU General Public License v3.0 | 5 votes |
def main(): viewer = Viewer() data = viewer.get_data() layout = viewer.create_ui(data) curdoc().add_root(layout) #partial_update = partial(update, viewer=viewer) #curdoc().add_periodic_callback(partial_update, 500)
Example #3
Source File: bokeh.py From thingflow-python with Apache License 2.0 | 5 votes |
def make_fig(self, plot_source): plot_specs = plot_source['plot_specs'] p = figure(plot_height=400, tools=TOOLS, y_axis_location='left', title=plot_specs.name) p.xaxis.axis_label = plot_specs.x_axis_label p.yaxis.axis_label = plot_specs.y_axis_label p.x_range.follow = "end" p.x_range.follow_interval = 10 p.x_range.range_padding = 0 # p.xaxis.formatter=DatetimeTickFormatter(dict(seconds=["%S"],minutes=["%M"],hours=["%d %B %Y"],days=["%d %B %Y"],months=["%d %B %Y"],years=["%d %B %Y"])) p.xaxis.major_label_orientation = pi/4 p.line(x=plot_specs.x_axis_label, y=plot_specs.y_axis_label, color="blue", source=plot_specs.source) p.circle(x=plot_specs.x_axis_label, y=plot_specs.y_axis_label, color="red", source=plot_specs.source) curdoc().add_periodic_callback(functools.partial(self.update, name=plot_specs.name), plot_specs.update_period) #period in ms return p
Example #4
Source File: bokeh.py From thingflow-python with Apache License 2.0 | 5 votes |
def run(self): print("In thread.run") self.figs = [self.make_fig(self.plotters[name]) for name in self.plotters] self.session = push_session(curdoc()) self.session.show(column(self.figs)) curdoc().title = 'AntEvent Streams' self.session.loop_until_closed()
Example #5
Source File: bokeh.py From histogrammar-python with Apache License 2.0 | 5 votes |
def view(plot,show=False): from bokeh.plotting import curdoc from bokeh.client import push_session if show: session = push_session(curdoc()) session.show(plot) else: curdoc().add_root(plot)
Example #6
Source File: crossbokeh.py From certitude with GNU General Public License v2.0 | 5 votes |
def create_figure(): # args = curdoc().session_context.request.arguments # with open('args.txt', 'w') as the_file: # the_file.write(str(curdoc().session_context.request.arguments['batchid'])) # the_file.write(str(args)) df = select_units() xs = df[x.value].values ys = df[y.value].values df['x'] = xs df['y'] = ys source.data = df.to_dict(orient='list') x_title = x.value.title() y_title = y.value.title() kw = dict() if x.value in discrete: kw['x_range'] = sorted(set(xs)) if y.value in discrete: kw['y_range'] = sorted(set(ys)) # kw['title'] = "%s" % (dir(args)) kw['title'] = "%s vs %s (%i elements)" % (x_title, y_title, len(df)) # hover = HoverTool(tooltips=[("Address", "@HostnameIP"), ("Malware", "@Malware"), ("Compromise", "@Compromise")]) p = figure(plot_width=500, plot_height=500, tools=[BoxSelectTool(), ResetTool()], **kw) p.xaxis.axis_label = x_title p.yaxis.axis_label = y_title if x.value in discrete: p.xaxis.major_label_orientation = pd.np.pi / 4 # c = np.where(pandata["Compromise"] > 0, "orange", "grey") # sz = np.where(pandata["Compromise"] > 0, 9 * , "grey") p.circle(x='x', y='y', source=source, size=15, selection_color="orange", alpha=0.8, nonselection_alpha=0.4, selection_alpha=0.6) return p