[雪峰磁针石博客]Bokeh数据可视化工具1快速入门
简介
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 into output_file("bokeh.html") #Constructing a basic line plot x = [1,2,3] y = [4,5,6] p = figure() p.line(x,y) show(p)
问题讨论:
https://groups.google.com/a/anaconda.com/forum/#!forum/bokeh
bug跟踪:https://github.com/bokeh/bokeh/issues
应用程序:Bokeh应用程序是在浏览器中运行的Bokeh渲染文档
Glyph:Glyph是Bokeh的基石,它们是线条,圆形,矩形等。
服务器:Bokeh服务器用于共享和发布交互式图表
小部件Widgets::Bokeh中的小部件是滑块,下拉菜单等
输出方法有:output_file('plot.html')和output_notebook()
构建图片的方式:
#Code to construct a figure from bokeh.plotting import figure # create a Figure object p = figure(plot_width=500, plot_height=400, tools="pan,hover")
绘图基础
线状图
#Creating a line plot #Importing the required packages from bokeh.io import output_file, show from bokeh.plotting import figure #Creating our data arrays used for plotting the line plot x = [5,6,7,8,9,10] y = [1,2,3,4,5,6] #Calling the figure() function to create the figure of the plot plot = figure() #Creating a line plot using the line() function plot.line(x,y) #Creating markers on our line plot at the location of the intersection between x and y plot.cross(x,y, size = 15) #Output the plot output_file('line_plot.html') show(plot)
柱形图
#Creating bar plots #Importing the required packages from bokeh.plotting import figure, show, output_file #Points on the x axis x = [8,9,10] #Points on the y axis y = [1,2,3] #Creating the figure of the plot plot = figure() #Code to create the barplot plot.vbar(x,top = y, color = "blue", width= 0.5) #Output the plot output_file('barplot.html') show(plot)
补丁图
#Creating patch plots #Importing the required packages from bokeh.io import output_file, show from bokeh.plotting import figure #Creating the regions to map x_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 figure plot = figure() #Building the patch plot plot.patches(x_region, y_region, fill_color = ['yellow', 'black', 'green'], line_color = 'white') #Output the plot output_file('patch_plot.html') show(plot)
散列图
#Creating scatter plots #Importing the required packages from bokeh.io import output_file, show from bokeh.plotting import figure #Creating the figure plot = figure() #Creating the x and y points x = [1,2,3,4,5] y = [5,7,2,2,4] #Plotting the points with a cirle marker plot.circle(x,y, size = 30) #Output the plot output_file('scatter.html') show(plot)
更多资源
#- cross() #- x() #- diamond() #- diamond_cross() #- circle_x() #- circle_cross() #- triangle() #- inverted_triangle() #- square() #- square_x() #- square_cross() #- asterisk() #Adding labels to the plot plot.figure(x_axis_label = "Label name of x axis", y_axis_label = "Label name of y axis") #Customizing transperancy of the plot plot.circle(x, y, alpha = 0.5) plot.circle(x, y, alpha = 0.5)
参考资料
- 本文最新版本地址
- 讨论 钉钉免费群21745728 qq群144081101 567351477
- 本文涉及的python测试开发库 谢谢点赞!
- 本文相关海量书籍下载
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Swift 简单总结
1. swift简单总结(一)—— 数据简单值和类型转换2. swift简单总结(二)—— 简单值和控制流3. swift简单总结(三)—— 循环控制和函数4. swift简单总结(四)—— 函数和类5. swift简单总结(五)—— 枚举和结构体6. swift简单总结(六)—— 协议扩展与泛型7. swift简单总结(七)—— 数据类型8. swift简单总结(八)—— 别名、布尔值与元组9. swift简单总结(九)—— 可选值和断言10. swift简单总结(十)—— 运算符11. swift简单总结(十一)—— 字符串和字符12. swift简单总结(十二)—— 集合类型之数组13. swift简单总结(十三)—— 集合类型之字典14. swift简单总结(十四)—— 控制流15. swift简单总结(十五)—— 控制转移语句16. swift简单总结(十六)—— 函数17. swift简单总结(十七)—— 闭包(Closures)18. swift简单总结(十八)—— 枚举19. swift简单总结(十九)—— 类和结构体20. swift简单总结(二十)—— 属性21. ...
- 下一篇
阿里云提示漏洞:destoon变量覆盖导致延时注入
出现漏洞 .../module/mall/my.inc.php .../backup/module/mall/my.inc.php 修复方法: my.inc.php里面所有的extract函数加上, EXTR_SKIP参数就可以 比如extract($item);修改成extract($item,EXTR_SKIP);
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Hadoop3单机部署,实现最简伪集群
- CentOS7安装Docker,走上虚拟化容器引擎之路
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS8编译安装MySQL8.0.19
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池