本文整理汇总了Python中bokeh.plotting.curdoc方法的典型用法代码示例。如果您正苦于以下问题:Python plotting.curdoc方法的具体用法?Python plotting.curdoc怎么用?Python plotting.curdoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.plotting
的用法示例。
在下文中一共展示了plotting.curdoc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import curdoc [as 别名]
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
示例2: main
# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import curdoc [as 别名]
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)
示例3: make_fig
# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import curdoc [as 别名]
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
示例4: view
# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import curdoc [as 别名]
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)
示例5: create_figure
# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import curdoc [as 别名]
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