五、多圖展示

from bokeh.io import output_notebook, show
from bokeh.plotting import figure

output_notebook()

在前面的章節(jié)中, 我們學(xué)習(xí)的都是在一張畫(huà)布上展示不同的數(shù)據(jù)。 但是我們時(shí)常需要在一張畫(huà)布上展示多張圖。

下面這段數(shù)據(jù)的定義將要用于后面的案例中.

x = list(range(11))
y0, y1, y2 = x, [10-i for i in x], [abs(i-5) for i in x]  

畫(huà)布行布局與列布局

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 分別代表三個(gè)畫(huà)布。 建立好三畫(huà)布后, 通過(guò)row()進(jìn)行展示, 也就是說(shuō), 它們?cè)谒骄€(xiàn)上展示一排。

網(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

通過(guò)gridplot定義網(wǎng)格的布局

下一章:六、圖片聯(lián)動(dòng)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容