当前位置: 首页>>代码示例>>Python>>正文


Python Session.store_objects方法代码示例

本文整理汇总了Python中bokeh.session.Session.store_objects方法的典型用法代码示例。如果您正苦于以下问题:Python Session.store_objects方法的具体用法?Python Session.store_objects怎么用?Python Session.store_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.session.Session的用法示例。


在下文中一共展示了Session.store_objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DataRange1d

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import store_objects [as 别名]
xdr_static = DataRange1d(sources=[source.columns("x_static")])
ydr = DataRange1d(sources=[source.columns("y")])

plot = Plot(x_range=xdr_static, y_range=ydr, min_border=50)

line_glyph = Line(x="x", y="y", line_color="blue")
plot.add_glyph(source, line_glyph)

line_glyph2 = Line(x="x", y="z", line_color="red")
plot.add_glyph(source, line_glyph2)

plot.add_layout(LinearAxis(), 'below')
plot.add_layout(LinearAxis(), 'left')

plot.add_tools(PanTool(), WheelZoomTool())

document.add(plot)
session.store_document(document)

link = session.object_link(document.context)
print("please visit %s to see plots" % link)
view(link)

print("\nanimating... press ctrl-C to stop")

while True:
    for i in  linspace(-2*pi, 2*pi, 50):
        source.data['x'] = x +i
        session.store_objects(source)
        time.sleep(0.05)
开发者ID:akansal1,项目名称:bokeh,代码行数:32,代码来源:line_animate.py

示例2: Dashboard

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import store_objects [as 别名]

#.........这里部分代码省略.........
        self.init_sources()
        self.document.add(self.construct())


# Sources
# -------

    def init_sources(self):
        """Initialize DataSource objects backing the dashboard elements."""

        columns = ['some', 'column', 'headers']
        self.columns = columns

        self.data_source = ColumnDataSource(data=dict(zip(columns, []*len(columns))))

# Construction
# ------------

    def construct(self):

        slider = self.slider()
        plot = self.plot()
        handson_table = self.handson_table()

        layout = VBox(children=[
            slider,
            plot,
            handson_table
            ])
        return layout

# Widgets
# -------

    def slider(self):
        slider = Slider(value=10, start=10, end=100, step=10, orientation="horizontal", title="Slider")
        slider.on_change('value', self.on_slider_change)

        return HBox(children=[slider], width=500)

    def on_slider_change(self, obj, attr, old, new):

    def handson_table(self):
        # Hands On Table Widget
        columns = [
            TableColumn(field="a", header="A"),
            TableColumn(field="b", header="B"),
            TableColumn(field="c", header="C"),
        ]

        return HandsonTable(source=self.data_source, columns=columns, width=800)

# Plots
# -----

    def plot(self):
        plot = curplot()
        hover = plot.select(dict(type=HoverTool))
        hover.tooltips = OrderedDict([
            ("type", " @type"),
        ])

        seabornify(plot)
        return plot

# Update Routine
# --------------

    def update(self):
        self.session.store_objects(self.data_source)

# Run
# ---

    def run(self, poll_interval=1):

        self.session.store_document(self.document)

        link = self.session.object_link(self.document.context)
        if self.show:
            import webbrowser
            webbrowser.open(link)
        else:
            print("Please visit %s to see the plots (press ctrl-C to exit)" % link)

        try:
            while True:
                self.session.load_document(self.document)
                sleep(poll_interval)
        except KeyboardInterrupt:
            print()
        except ConnectionError:
            print("Connection to bokeh-server was terminated.")

if __name__ == "__main__":

    args = parse_args()

    dashboard = Dashboard(**vars(args))
    dashboard.run()
开发者ID:kdodia,项目名称:snippets,代码行数:104,代码来源:dashboard_template.py


注:本文中的bokeh.session.Session.store_objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。