gpt4 book ai didi

python - 在 Markdown 中嵌入 Bokeh 图

转载 作者:行者123 更新时间:2023-12-02 09:25:15 27 4
gpt4 key购买 nike

我找不到任何有关在 Markdown 样式文档中嵌入 Bokeh 图的文档。有没有一种简单的方法可以使用 bokeh.embed.components 的 script 和 div 标签来做到这一点?

最佳答案

如果您的 Markdown 风格支持 <embed>标签这可以使用 .htmlBokeh's output_file() 生成的文件.

在Python中:

from bokeh.plotting import figure, output_file, show

p = figure(title="example", x_axis_label='x', y_axis_label='y')

output_file("example.html")
show(p) # Needed to actually save the file

在 Markdown 中:

<embed type="text/html" src="relative/path/to/example.html" width="600" height="400"></embed>

请注意 widthheight属性是必需的,因为它不会自动调整大小。

此方法确实有一个小缺点,即需要将绘图文件与 Markdown 一起保存。

关于python - 在 Markdown 中嵌入 Bokeh 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34406307/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com