数据可视化- bokeh

Posted keven0526

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据可视化- bokeh相关的知识,希望对你有一定的参考价值。


from bokeh.io import output_notebook, output_file, show
from bokeh.charts import Scatter, Bar, BoxPlot, Chord
from bokeh.layouts import row

import seaborn as sns

# 导入数据
exercise = sns.load_dataset('exercise')

output_notebook()
#output_file('test.html')

# 散点图
p = Scatter(data=exercise, x='id', y='pulse', title='exercise dataset')
show(p)

# 柱状图
p = Bar(data=exercise, values='pulse', label='diet', stack='kind', title='exercise dataset')
show(p)

# 盒子图
box1 = BoxPlot(data=exercise, values='pulse', label='diet', color='diet', title='exercise dataset')
box2 = BoxPlot(data=exercise, values='pulse', label='diet', stack='kind', color='kind', title='exercise dataset')
show(row(box1, box2))

# 弦图 Chord
chord1 = Chord(data=exercise, source="id", target="kind")
chord2 = Chord(data=exercise, source="id", target="kind", value="pulse")

show(row(chord1, chord2))

from bokeh.plotting import figure
import numpy as np

p = figure(plot_width=400, plot_height=400)
# 方框
p.square(np.random.randint(1,10,5), np.random.randint(1,10,5), size=20, color="navy")

# 圆形
p.circle(np.random.randint(1,10,5), np.random.randint(1,10,5), size=10, color="green")
show(p)

以上是关于数据可视化- bokeh的主要内容,如果未能解决你的问题,请参考以下文章

Python爬取B站历史观看记录并用Bokeh做数据可视化

推荐一款数据可视化利器:Bokeh

数据可视化- bokeh

Bokeh 教程:Python 交互式可视化库

超详细,Python库 Bokeh 数据可视化实用指南

Bokeh 0.12.3dev3,Python 交互式可视化库