Store bokeh html file in shared location

时间:2019-04-16 22:16:19

标签: bokeh

I have a bokeh html file that I would like to store in a central shared location. It is important that the file stays in the html format as it has tooltips etc that are key parts of the way the data is being visualised.

Ideally, I am hoping to have hyperlinks in an Excel spreadsheet that will point to the location of these bokeh files. My plan is to send out this spreadsheet to the relevant parties and they will be able to access the bokeh files through the hyperlinks.

I have tested putting the bokeh files in a OneDrive folder and then sharing this, but clicking on the hyperlink just effectively opens a text viewer which displays the html behind the bokeh.

Is there a way to achieve what I'm trying to do?

2 个答案:

答案 0 :(得分:0)

您可以使用file_html获取绘图的html代码,并使用标准Python操作将输出写入文件。

from bokeh.plotting import figure, show
from bokeh.resources import CDN
from bokeh.embed import file_html

p = figure(plot_width=400, plot_height=400)

# add a circle renderer with a size, color, and alpha
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)

# show the results
show(p)
html = file_html(p, CDN, "myplot")

outFile = open('/home/jasper/Dropbox/plot.html', 'w')
outFile.write(html)
outFile.close()

答案 1 :(得分:0)

我发现最好的解决方案是使用Github。

  1. 创建一个名为[GITHUB_USERNAME].github.io的存储库
  2. 按照此video
  3. 中的说明进行操作
  4. 找到您在https://[GITHUB_USERNAME].github.io/[FILE_NAME].html上传的html文件