html - 如何在散景中显示文本同时保留线间隙
问题描述
我正在尝试使用 Bokeh 2.0.1 生成由绘图和一些文本组成的报告,并且我正在尝试保留我输入的文本中的原始行间距bokeh.layouts.gridplot
。
但是,我看到在生成 HTML 文件后,所有的行间距都被删除了,基本上,所有的段落都被合并成一个连续的句子。我不确定为什么会这样。我在 Bokeh 文档中没有找到关于这个问题的太多帮助。
这是我试图开始工作的代码部分的一个最小示例。
from bokeh.layouts import gridplot
from bokeh.models import Paragraph
from bokeh.plotting import output_file, save
sampText = "PARAGRAPH 1: This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text.\n
PARAGRAPH 2: This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text."
fig1 = ...
fig2 = ...
text = Paragraph(text = sampText, width = 1500, height_policy = "auto", style = {'fontsize': '10pt', 'color': 'black', 'font-family': 'arial'})
output_file(filename = "myMinimalExampleOutput" + ".html")
output = gridplot([fig1, fig2, text], ncols = 1, plot_width = 1500, sizing_mode = 'scale_width')
save(output)
有人可以指出为什么会这样吗?
解决方案
这就是 HTML 的工作原理——它从文本中删除所有“不必要的”空格。
为了使您的两个段落起作用,您必须将它们中的每一个都包装在<p></p>
. 但由于Paragraph
生成相同的标签,您不能使用该类。使用常规Div
并将其text
输入参数设置为您要呈现的 HTML。
Div(text='<p>paragraph 1</p><p>paragraph 2</p>')
推荐阅读
- javascript - Math.pow 在 calc 中返回 0
- android - 如何在 ionic 2 中实现 In App Purcharse?
- javascript - For循环和2个数组
- spring - Spring:如何从数据库中显示百里香中的图像
- php - 调用未定义的方法 Illuminate\Database\Query\Builder::appends() 错误
- javascript - 无法 console.log 获取结果
- python - 无限期地绘制matplotlib子图?
- docker - pycharm错误运行,在docker debug上找不到运行器
- google-bigquery - Scio saveAsTypedBigQuery 写入分区,用于 SCollection of Typed Big Query 案例类
- c - 静态内存可以延迟分配吗?