[雪峰磁针石博客]Bokeh数据可视化工具1快速入门

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

简介

数据可视化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 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)

image.png

问题讨论:

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)

image.png

柱形图


#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)

image.png

补丁图


#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)

image.png

散列图


#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)

image.png

更多资源


#- 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)

参考资料

相关文章
|
机器学习/深度学习 数据挖掘 Python
[雪峰磁针石博客]数据分析工具pandas快速入门教程1-开胃菜
简介 Pandas是用于数据分析的开源Python库,也是目前数据分析最重要的开源库。它能够处理类似电子表格的数据,用于快速数据加载,操作,对齐,合并等。为Python提供这些增强功能,Pandas的数据类型为:Series和DataFrame。
|
数据挖掘 C语言 Python
[雪峰磁针石博客]数据分析工具pandas快速入门教程4-数据汇聚
我们需要的所有信息可能记录在单独的文件和数据帧中。例如,可能有一个公司信息单独表和股票价格表,数据被分成独立的表格以减少冗余信息。 连接 添加行4-1.py import pandas as pd df1 = pd.
|
Web App开发 测试技术 API
[雪峰磁针石博客]可爱的python测试开发库
可爱的python测试开发库 请在github上点赞,谢谢! 测试开发 Web UI测试自动化 splinter - web UI测试工具,基于selnium封装。 链接 selenium - web UI自动化测试。
|
数据挖掘 索引 Python
[雪峰磁针石博客]使用pandas数据分析工具处理excel
pandas有强大的excel数据处理和导入处理功能,本文简单介绍pandas在csv和excel等格式方面处理的应用及绘制图表等功能。 pandas处理excel依赖xlutils, OpenPyXL, XlsxWriter等库。
|
Web App开发 存储 测试技术
[雪峰磁针石博客]数据仓库快速入门教程1简介
数据仓库是从各种渠道收集和管理数据的技术,可提供有意义的业务洞察,战略性地使用数据。它用于查询和分析而不是事务处理,是将数据转换为信息并及时向用户提供的过程。 决策支持数据库(数据仓库)与组织的运营数据库分开维护。
|
Web App开发 机器学习/深度学习 算法
[雪峰磁针石博客]2019-Python最佳数据科学工具库
说明 以下库都可以在python测试开发库中找到,github地址:https://github.com/china-testing/python-api-tesing 相关书籍:https://china-testing.github.io/python_books.html 核心库 NumPy Numerical Python的缩写,专为数学运算而设计。

热门文章

最新文章