使用rbokeh将图嵌入网页 [英] Embedding plot to web page using rbokeh
问题描述
我已经使用rbokeh在R中创建了一个图,我想将其转换为HTML/Javascript以便将其嵌入到网页中.我目前可以在python上使用mpld3来实现这一点(而且我知道python上的bokeh也可以做到这一点),但我希望能够在R中使用rbokeh来实现.因此,基本上我正在寻找与Python的mpld3类似的东西.fig_to_html(),例如:
I have created a plot in R using rbokeh and I want to convert it to HTML/Javascript in order to embed it inside a web page. I'm currently able to achieve this with mpld3 on Python (and I know that bokeh on python does it too) but I want to be able to do this with rbokeh in R. So basically I'm looking for something similar to Python's mpld3.fig_to_html(), e.g:
fig, ax = plt.subplots()
ax.p1 = plt.bar(...)
html = mpld3.fig_to_html(fig) # <- converts the plot to html/javascript!
print html # prints out the html/javascript code as text
或使用Python的bokeh模块:embed.autoload_static()
Or using Python's bokeh module: embed.autoload_static()
可以将rbokeh图转换为html/JavaScript代码吗?
Can rbokeh plots be converted to html/JavaScript code?
非常感谢.
推荐答案
到目前为止,saveWidget似乎是最接近我想要的东西,因此感谢 hrbrmstr .我想避免每次将图形导出到html时都不必从磁盘上读写,但这还不可能.
It appears that, to date, saveWidget is the closest to what I want, so thanks hrbrmstr. I wanted to avoid having to read and write from the disk every time a graph is exported to html but it's not possible yet.
这篇关于使用rbokeh将图嵌入网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!