from bokeh.io import output_notebook, show
from bokeh.plotting import figure
output_notebook()
在前面的章節(jié)中舀奶, 我們學(xué)習(xí)的都是在一張畫布上展示不同的數(shù)據(jù)。 但是我們時常需要在一張畫布上展示多張圖粥诫。
下面這段數(shù)據(jù)的定義將要用于后面的案例中.
x = list(range(11))
y0, y1, y2 = x, [10-i for i in x], [abs(i-5) for i in x]
畫布行布局與列布局
from bokeh.layouts import row
# create a new plot
s1 = figure(width=250, plot_height=250)
s1.circle(x, y0, size=10, color="navy", alpha=0.5)
# create another one
s2 = figure(width=250, height=250)
s2.triangle(x, y1, size=10, color="firebrick", alpha=0.5)
# create and another
s3 = figure(width=250, height=250)
s3.square(x, y2, size=10, color="olive", alpha=0.5)
# show the results in a row
show(row(s1, s2, s3))
row_plots.PNG
上面代碼中, s1
, s2
, s3
分別代表三個畫布。 建立好三畫布后蔑水, 通過row()
進行展示邢锯, 也就是說, 它們在水平線上展示一排搀别。
網(wǎng)格布局
from bokeh.layouts import gridplot
# create a new plot
s1 = figure(width=250, plot_height=250)
s1.circle(x, y0, size=10, color="navy", alpha=0.5)
# create another one
s2 = figure(width=250, height=250)
s2.triangle(x, y1, size=10, color="firebrick", alpha=0.5)
# create and another
s3 = figure(width=250, height=250)
s3.square(x, y2, size=10, color="olive", alpha=0.5)
# put all the plots in a gridplot
p = gridplot([[s1, s2], [s3, None]], toolbar_location=None)
# show the results
show(p)
grap_plots.PNG
通過gridplot
定義網(wǎng)格的布局
下一章:六丹擎、圖片聯(lián)動