以文字溝通

使用 Bokeh 製作互動式資料視覺化

George Boorman

Core Curriculum Manager, DataCamp

我們的圖

無標題的圖

使用 Bokeh 製作互動式資料視覺化

加入標題

fig = figure(x_axis_label='Assists per Game', y_axis_label='Points per Game',

title="Points vs. Assists by Conference")
fig.circle(x='assists', y='points', source=east, color='blue', legend_label='East') fig.circle(x='assists', y='points', source=west, color='red', legend_label='West') output_file(filename="points_vs_assists_by_conference.html") show(fig)

含標題的圖

使用 Bokeh 製作互動式資料視覺化

自訂標題

fig.title.text_font_size = "30px"

fig.title.align = "center"
output_file(filename="modified_title.html") show(fig)

自訂標題

使用 Bokeh 製作互動式資料視覺化

修改圖例

fig.legend.title = "Conference"

fig.legend.location = "bottom_right"
show(fig)
legend.location
"top_left"
"top_right"
"bottom_left"
"bottom_right"

斜體圖例標題

使用 Bokeh 製作互動式資料視覺化

圖例標題字型樣式

legend.title_text_font_style
"bold"
"normal"
"italic"
使用 Bokeh 製作互動式資料視覺化

圖例標題字型樣式

fig.legend.title_text_font_style = "normal"

output_file(filename="normal_legend_title.html") show(fig)

一般圖例標題

使用 Bokeh 製作互動式資料視覺化

顯示互動式圖例

fig.legend.click_policy = "hide"

output_file(filename="interactive_legend.html") show(fig)

互動式圖例

使用 Bokeh 製作互動式資料視覺化

資料集

print(bakery.shape)
(17486, 6)
print(bakery.columns)
Index(['transaction', 'items', 'day_time', 'day_type', 'date', 'sales'],
dtype='object')
使用 Bokeh 製作互動式資料視覺化

一起來練習吧!

使用 Bokeh 製作互動式資料視覺化

Preparing Video For Download...