绘图工具bokeh
Bokeh是一个专门针对Web浏览器的呈现功能的交互式可视化Python库。这是Bokeh与其它可视化库最核心的区别。
Bokeh接口
包引用from?bokeh.io?import?output_notebook,output_file,showfrom?bokeh.charts?import?Scatter,Bar,BoxPlot,Chordfrom?bokeh.layouts?import?rowimport?seaborn?as?snsexercise = sns.load_dataset(‘exercise‘)output_notebook()
散点图 Scatter
示例代码:
# 散点图p = Scatter(data=exercise,x=‘id‘,y=‘pulse‘,title=‘exercise dataset‘)show(p)
运行结果:
?
柱状图 Bar
示例代码:
# 柱状图p = Bar(data=exercise,values=‘pulse‘,label=‘diet‘,stack=‘kind‘,title=‘exercise dataset‘)show(p)
运行结果:
?
盒子图 BoxPlot
示例代码:
# 盒子图box1 = BoxPlot(data=exercise,color=‘diet‘,title=‘exercise dataset‘)box2 = BoxPlot(data=exercise,color=‘kind‘,title=‘exercise dataset‘)show(row(box1,box2))
运行结果:
?
?
<ignore_js_op>
? 展示多个节点之间的联系
? 连线的粗细代表权重
示例代码:
# 弦图 Chordchord1 = Chord(data=exercise,source="id",target="kind")chord2 = Chord(data=exercise,target="kind",value="pulse")show(row(chord1,chord2))
运行结果:
?
?
<ignore_js_op>
示例代码:
from?bokeh.plotting?import?figureimport?numpy?as?npp = figure(plot_width=400,plot_height=400)# 方框p.square(np.random.randint(1,10,5),np.random.randint(1,size=20,color="navy")# 圆形p.circle(np.random.randint(1,size=10,color="green")show(p)
运行结果:
?
<ignore_js_op> 更多技术资讯可关注:gzitcast (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |