我需要在页面上有 2 个散景图。我需要它们彼此分开。目前我只能有一个数字(使用网格/行/列的多个图)但不能有多个数字。
请参阅有关如何在行或列中附加数字的文档。
有关如何在同一行中绘制图形的示例,请参见
from bokeh.io import output_file, show
from bokeh.layouts import row
from bokeh.plotting import figure
output_file("layout.html")
x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]
# create a new plot
s1 = figure(plot_width=250, plot_height=250, title=None)
s1.circle(x, y0, size=10, color="navy", alpha=0.5)
# create another one
s2 = figure(plot_width=250, plot_height=250, title=None)
s2.triangle(x, y1, size=10, color="firebrick", alpha=0.5)
# create and another
s3 = figure(plot_width=250, plot_height=250, title=None)
s3.square(x, y2, size=10, color="olive", alpha=0.5)
# put the results in a row
show(row(s1, s2, s3))
Run Code Online (Sandbox Code Playgroud)
同样,您可以使用将结果放在一列中
show(column(s1, s2, s3))
Run Code Online (Sandbox Code Playgroud)
当然,你可以将两者结合起来创建一个网格,所以如果你有一个数字列表,比如graphs,你可以做类似的事情
cols = []
row_num = 3
for i in range(0, len(graphs), row_num):
r = row(graphs[i: i + row_num])
cols.append(r)
show(column(cols))
Run Code Online (Sandbox Code Playgroud)
小智 -1
from bokeh.plotting import figure
from bokeh.embed import file_html
from bokeh.resources import CDN
x = [1,4,6]
y = [4,6,9]
plot = figure(width=300, height=300)
plot.line(x, y)
html1 = file_html(plot, CDN, 'my plot')
Run Code Online (Sandbox Code Playgroud)
这样您就可以创建多个绘图并使用标准 jinja2 语法插入它们
喜欢:
<h1> First plot </h1>
{{ html1 }}
<h1> Second plot </h1>
{{ html2 }}
Run Code Online (Sandbox Code Playgroud)
您可以在这里找到更多信息
您也可以尝试使用选项卡面板
| 归档时间: |
|
| 查看次数: |
9480 次 |
| 最近记录: |