为了账号安全,请及时绑定邮箱和手机立即绑定

搜索 Bokeh数据可视化工具1快速入门

标签:
Python

python数据可视化库最突出的为Matplotlib、Seaborn和Bokeh。前两个,Matplotlib和Seaborn,绘制静态图。Bokeh可以绘制交互式图。

安装

conda install bokeh

pip2 install bokeh

pip3 install bokeh

检验安装

from bokeh.plotting import figure, output_file, show#HTML file to output your plot intooutput_file("bokeh.html")#Constructing a basic line plotx = [1,2,3]

y = [4,5,6]

p = figure()

p.line(x,y)

show(p)

webp

image.png



应用程序:Bokeh应用程序是在浏览器中运行的Bokeh渲染文档

Glyph:Glyph是Bokeh的基石,它们是线条,圆形,矩形等。

服务器:Bokeh服务器用于共享和发布交互式图表

小部件Widgets::Bokeh中的小部件是滑块,下拉菜单等

输出方法有:output_file('plot.html')和output_notebook()

构建图片的方式:

#Code to construct a figurefrom bokeh.plotting import figure# create a Figure objectp = figure(plot_width=500, plot_height=400, tools="pan,hover")

绘图基础

线状图

#Creating a line plot#Importing the required packagesfrom bokeh.io import output_file, showfrom bokeh.plotting import figure#Creating our data arrays used for plotting the line plotx = [5,6,7,8,9,10]

y = [1,2,3,4,5,6]#Calling the figure() function to create the figure of the plotplot = figure()#Creating a line plot using the line() functionplot.line(x,y)#Creating markers on our line plot at the location of the intersection between x and yplot.cross(x,y, size = 15)#Output the plotoutput_file('line_plot.html')

show(plot)

webp

image.png

柱形图

#Creating bar plots#Importing the required packagesfrom bokeh.plotting import figure, show, output_file#Points on the x axisx = [8,9,10]#Points on the y axisy = [1,2,3]#Creating the figure of the plotplot = figure()#Code to create the barplotplot.vbar(x,top = y, color = "blue", width= 0.5)#Output the plotoutput_file('barplot.html')

show(plot)

webp

image.png

补丁图

#Creating patch plots#Importing the required packagesfrom bokeh.io import output_file, showfrom bokeh.plotting import figure#Creating the regions to mapx_region = [[1,1,2,], [2,3,4], [2,3,5,4]]

y_region = [[2,5,6], [3,6,7], [2,4,7,8]]#Creating the figureplot = figure()#Building the patch plotplot.patches(x_region, y_region, fill_color = ['yellow', 'black', 'green'], line_color = 'white')#Output the plotoutput_file('patch_plot.html')

show(plot)

webp

image.png

散列图

#Creating scatter plots#Importing the required packagesfrom bokeh.io import output_file, showfrom bokeh.plotting import figure#Creating the figureplot = figure()#Creating the x and y pointsx = [1,2,3,4,5]

y = [5,7,2,2,4]#Plotting the points with a cirle markerplot.circle(x,y, size = 30)#Output the plotoutput_file('scatter.html')

show(plot)

webp

image.png

更多资源

#- cross()#- x()#- diamond()#- diamond_cross()#- circle_x()#- circle_cross()#- triangle()#- inverted_triangle()#- square()#- square_x()#- square_cross()#- asterisk()#Adding labels to the plotplot.figure(x_axis_label = "Label name of x axis", y_axis_label = "Label name of y axis")#Customizing transperancy of the plotplot.circle(x, y, alpha = 0.5)

plot.circle(x, y, alpha = 0.5)



作者:python作业AI毕业设计
链接:https://www.jianshu.com/p/76b71ce34060


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

举报

0/150
提交
取消