BokehWidget¶
Show Bokeh plots in Flexx. Example:
import numpy as np
from bokeh.plotting import figure
from flexx import app, event, ui
x = np.linspace(0, 6, 50)
p1 = figure()
p1.line(x, np.sin(x))
p2 = figure()
p2.line(x, np.cos(x))
class Example(app.PyComponent):
def init(self):
with ui.HSplit():
ui.BokehWidget.from_plot(p1)
ui.BokehWidget.from_plot(p2)
Also see examples: bokehdemo.py.
-
class
flexx.ui.
BokehWidget
(*init_args, **kwargs)¶ Inherits from:
Widget
A widget that shows a Bokeh plot object.
For Bokeh 0.12 and up. The plot’s
sizing_mode
property is set tostretch_both
unless it was set to something other thanfixed
. Other responsive modes are ‘scale_width’, ‘scale_height’ and ‘scale_both`, which all keep aspect ratio while being responsive in a certain direction.This widget is, like all widgets, a JsComponent; it lives in the browser, while the Bokeh plot is a Python object. Therefore we cannot simply use a property to set the plot. Use
ui.BokehWidget.from_plot(plot)
to instantiate the widget from Python.attributes: plot
actions: set_plot_components
-
plot
¶ attribute – The JS-side of the Bokeh plot object.
-
set_plot_components
(d)¶ action – Set the plot using its script/html components.
-