码迷,mamicode.com
首页 > 其他好文 > 详细

数据可视化- bokeh

时间:2017-03-16 20:20:39      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:lang   imp   chord   import   tput   nav   chart   book   sns   


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

标签:lang   imp   chord   import   tput   nav   chart   book   sns   

原文地址:http://www.cnblogs.com/xuehaozhe/p/shu-ju-ke-shi-hua-bokeh.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!