📜  散景 – 地块的水平布局

📅  最后修改于: 2022-05-13 01:55:44.473000             🧑  作者: Mango

散景 – 地块的水平布局

Bokeh 包括多个用于排列绘图和小部件的布局选项。它们使排列多个组件以创建交互式仪表板或数据应用程序成为可能。布局函数可让您构建图表和小部件的网格。您可以根据需要将任意多的行、列或网格嵌套在一起。此外,散景布局支持多种“大小调整模式”。这些大小调整模式允许绘图和小部件根据浏览器窗口调整大小。

在 Bokeh Row 布局中,所有图都将仅显示在一行中。这可以使用 Bokeh 下支持的行布局函数来完成:

句法:

方法:



  • 导入模块
  • 创建数据
  • 通常创建多个绘图,就好像它们彼此独立一样。
  • 使用 rows() 将它们组合在一个布局中
  • 显示图

例子:

Python3
# python program for bokeh row layout
from bokeh.io import output_file, show
from bokeh.layouts import row
from bokeh.plotting import figure
  
# output will be in output.html
output_file("output.html")
  
x = list(range(11))
# y will be same as x
y = x
# y0 divide every element of x by 2
y0 = [i/2 for i in x]
# y1 multiply every element of xby 2
y1 = [i*2 for i in x]
  
# now creating three plots
plot1 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot1.circle(x, y, size=12, color="#53777a", alpha=0.8)
  
plot2 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot2.triangle(x, y0, size=12, color="#c02942", alpha=0.8)
  
plot3 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot3.square(x, y1, size=12, color="#d95b43", alpha=0.8)
  
# now creating row layout
show(row(plot1, plot2, plot3))


Python3
from bokeh.io import output_file, show
from bokeh.layouts import row
from bokeh.plotting import figure
  
output_file("output.html")
  
x = list(range(11))
# y0 is same as x
y0 = x
# y1 is every element of x %2
y1 = [i % 2 for i in x]
# y1 is every element of x %10
y2 = [i % 10 for i in x]
  
plot1 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot1.circle(x, y0, size=12, color="#53777a", alpha=0.8)
  
plot2 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot2.triangle(x, y1, size=12, color="#c02942", alpha=0.8)
  
plot3 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot3.square(x, y2, size=12, color="#d95b43", alpha=0.8)
  
show(row(plot1, plot2, plot3))


输出 :

例子:

蟒蛇3

from bokeh.io import output_file, show
from bokeh.layouts import row
from bokeh.plotting import figure
  
output_file("output.html")
  
x = list(range(11))
# y0 is same as x
y0 = x
# y1 is every element of x %2
y1 = [i % 2 for i in x]
# y1 is every element of x %10
y2 = [i % 10 for i in x]
  
plot1 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot1.circle(x, y0, size=12, color="#53777a", alpha=0.8)
  
plot2 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot2.triangle(x, y1, size=12, color="#c02942", alpha=0.8)
  
plot3 = figure(plot_width=200, plot_height=250, background_fill_color="#fafafa")
plot3.square(x, y2, size=12, color="#d95b43", alpha=0.8)
  
show(row(plot1, plot2, plot3))

输出 :