相关疑难解决方法(0)

使用Python/bokeh在网站中嵌入绘图

我试图在个人网站上静态嵌入散景图,并遇到一些我不理解的行为.基本上,我使用散景生成一个情节如下:

import bokeh.plotting as bplt
import numpy as np

x=np.random.random(100)
y=np.random.random(100)

bplt.output_file("t.html")
plot=bplt.line(x,y)

##the following line refers to the bokeh installed on my home computer
print plot.create_html_snippet(
           static_path='/usr/local/lib/python2.7/site-packages/bokeh/server/static/')

##the following line refers to the bokeh installed on my remote computer
#print plot.create_html_snippet(
#           static_path='/opt/anaconda/lib/python2.7/site-packages/bokeh/server/static/')
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好.这会生成一个看起来像的文件(random garbage).embed.js,并打印一个包含html语法的字符串,我手动将其复制到我正在调用的html文件中testembed.html,我在下面转载:

<html>
<body>

<h2>Simple Embed Example</h2>
<p>This is where my plot should be:</p>
<p>
<!--The next 4 lines are the output of the print statement from the python code-->
<script src="ccbd451a-6995-4dd2-b99c-e4140b362997.embed.js" …
Run Code Online (Sandbox Code Playgroud)

python bokeh

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

bokeh ×1

python ×1