小编JHu*_*Huw的帖子

Bokeh:将vars传递给CustomJS for Widgets

关于Bokeh的一个好处是,可以从Python层指定回调,该回调可以在javascript级别上执行操作,而无需使用bokeh-server.因此,可以创建在浏览器中运行的交互式小部件,而无需运行Ipython或Bokeh服务器.

0.9.3.文档提供了一个我可以在ipython笔记本中重现的示例:http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#cutomjs-for-widgets

from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider
from bokeh.plotting import figure, output_file, show

output_file("callback.html")
x = [x*0.005 for x in range(0, 200)]
y = x

source = ColumnDataSource(data=dict(x=x, y=y))

plot = figure(plot_width=400, plot_height=400)
plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

callback = CustomJS(args=dict(source=source), code="""
        var data = source.get('data');
        var f = cb_obj.get('value')
        x = data['x']
        y = data['y']
        for (i = 0; i < x.length; i++) {
            y[i] = Math.pow(x[i], f)
        }
        source.trigger('change');
    """)

slider …
Run Code Online (Sandbox Code Playgroud)

javascript python bokeh jupyter-notebook

5
推荐指数
1
解决办法
1635
查看次数

将python库添加到google datalab环境中

我在歌云平台上使用谷歌数据库.在第一次尝试时工作得很好,我喜欢现在在云中运行一个jupyter笔记本服务器是多么容易(比启动本地主机服务器更快).这是梦幻般的.

但是现在我想安装基本数据库环境中没有包含的python库(特别是我需要Bokeh绘图库).

所以我从谷歌云控制台开了一个谷歌云外壳,在那里我管理这个jupyter笔记本实例,安装了miniconda,然后是散景库.一切都运行没有错误(例如散景安装几个依赖项),但我在datalab上的jupyter笔记本(可以导入其他库如numpy)仍然给我一个"没有名为bokeh.plotting的模块"错误.

有任何想法吗?提前致谢.

anaconda bokeh google-cloud-datalab

5
推荐指数
1
解决办法
1600
查看次数