使用文本进行交流

使用 Bokeh 进行交互式数据可视化

George Boorman

Core Curriculum Manager, DataCamp

我们的图

plot_without_title

使用 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)

plot_with_title

使用 Bokeh 进行交互式数据可视化

自定义标题

fig.title.text_font_size = "30px"

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

customized_title

使用 Bokeh 进行交互式数据可视化

修改图例

fig.legend.title = "Conference"

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

italic_legend_title

使用 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)

normal_legend_title

使用 Bokeh 进行交互式数据可视化

显示交互式图例

fig.legend.click_policy = "hide"

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

interactive_legend

使用 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...