Matplotlib简介
Matplotlib是受MATLAB的启发构建的。MATLAB是数据绘图领域广泛使用的语言和工具。MATLAB语言是面向过程的。利用函数的调用,MATLAB中可以轻松的利用一行命令来绘制直线,然后再用一系列的函数调整结果。Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形 。通过Matplotlib,开发者可以仅需要几行代码,便可以生成绘图,直方图,功率谱,条形图,错误图,散点图等。其功能十分强大,对于数据分析工作有极大的帮助,深受数据分析工作者喜爱。
matplotlib的安装
python - m pip install matplotlib
本文主要通过配置参数、代码示例,介绍Matplotlib库绘制各类图形的方法
参数 释义 axex 坐标轴边界和表面的颜色、坐标刻度值、网格显示 figure 控制dpi、边界颜色、图形大小、和子区( subplot)设置 font 字体集(font family)、字体大小和样式设置 grid 设置网格颜色和线性 legend 设置图例和其中的文本的显示 line 设置线条(颜色、线型、宽度等)和标记 patch 填充2D空间的图形对象,如多边形和圆。控制线宽、颜色和抗锯齿设置等 savefig 可以对保存的图形进行单独设置。例如,设置渲染的文件的背景 verbose 设置matplotlib在执行期间信息输出,如silent、helpful、debug和debug-annoying xticks、yticks x,y轴的主刻度和次刻度设置颜色、大小、方向,以及标签大小
绘制图形时,不同的变量可能用不同的线条表示,因此可以通过线条属性让图像更美观
字符 含义 ‘-’ 实线 ‘—’ 破折线 ‘-.’ 点划线样式 ‘:’ 虚线样式
一条线条上,对于线上各个观测值可能通过特定的标记进行表示
标记 描述 ‘.’ 点标记 ‘,’ 像素标记 ‘o’ 圆标记 ‘v’ 倒三角标记 ‘^’ 正三角标记 ‘<’ 左三角标记 ‘>’ 右三角标记 ‘1’ 下箭头标记 ‘2’ 上箭头标记 ‘3’ 左箭头标记 ‘4’ 右箭头标记 ‘s’ 正方形标记 ‘p’ 五边形标记 ‘*’ 星形标记 ‘h’ 六边形标记 1 ‘H’ 六边形标记 2 ‘+’ 加号标记 ‘x’ X 标记 ‘D’ 菱形标记 ‘d’ 窄菱形标记 |’ 竖直线标记 ‘_’ 水平线标记
设置线条的颜色、填充的颜色等等。此外可使用HTML十六进制字符串 color=’#123456’ 使用合法的HTML颜色名字(’red’,’chartreuse’等),也可以传入一个归一化到[0,1]的RGB元祖, color=(0.3,0.3,0.4)。
别名 颜色 b 蓝色 g 绿色 r 红色 y 黄色 c 青色 k 黑色 m 洋红色 w 白色
tip:通过向如matplotlib.pyplot.axes()或者matplotlib.pyplot.subplot()这样的方法提供一个axisbg参数,可以指定坐标背景色。
在数据处理时,一般通过numpy库与matplotlib一起使用,通过本地读取数据-数据处理-数据可视化步骤完成数据分析,为重点介绍matplotlib库的使用,下文自行构造数据(注意中文在图形中的显示以防乱码)
pip install numpy
折线图
import numpy as np
import matplotlib. pyplot as plt
x= np. linspace( - 200 , 200 , 5 )
y= x** 2
plt. plot( x, y)
plt. show( )
y1= np. sin( x)
plt. plot( x, y1)
plt. show( )
散点图
height = [ 61 , 162 , 165 , 70 , 182 , 15 , 173 , 15 ]
weight = [ 50 , 31 , 53 , 98 , 80 , 40 , 69 , 55 ]
plt. scatter( height, weight, s= 100 , c= 'blue' , marker= '<' , alpha= 0.8 , )
plt. show( )
条形图
y= [ 20 , 10 , 30 , 25 , 15 ]
index= np. arange( len ( y) )
pl= plt. bar( x= index, height= y, width= 0.5 , color= 'orange' )
plt. show( )
饼图
labels= 'a' , 'b' , 'c' , 'd'
fracs= [ 17 , 33 , 49 , 18 ]
explode= [ 0 , 0.05 , 0 , 0 ]
plt. pie( x= fracs, labels= labels, autopct= '%1.1f%%' , explode= explode, shadow= True )
plt. show( )
箱线图
np. random. seed( 100 )
data1= np. random. normal( size= ( 1000 , 4 ) , loc= 0 , scale= 1 )
labels= [ 'A' , 'B' , 'C' , 'D' ]
plt. boxplot( data1, labels= labels)
plt. show( )
面向对象方法绘图
import numpy as np
import matplotlib. pyplot as plt
from pylab import *
m= np. arange( 0 , 10 , 1 )
n= np. random. randn( len ( m) )
plt. plot( m, n)
plt. title( 'pyplot' )
plt. show( )
x= arange( 0 , 10 , 1 )
y= randn( len ( x) )
plot( x, y)
title( 'pylab' )
show( )
a= np. arange( 0 , 15 , 1 )
b= np. random. randn( len ( a) )
fig= plt. figure( )
ax= fig. add_subplot( 211 )
l, = plt. plot( a, b)
t= ax. set_title( "object-oriented" )
plt. show( )
绘制子图
import numpy as np
import matplotlib. pyplot as plt
'''
matplotlib对象简介
FigureCanvas--画布
Figure--------图
Axes----------坐标轴
1. fig=plt.figure()
Figure 实例
可以添加Axes实例
2.ax=fig.add_subplot(111) ----添加子图
返回Axes实例
参数一:子图总行数
参数二:子图总列数
参数三:子图位置
在Figure上添加Axes的常用方法
'''
x= np. arange( 1 , 100 )
fig= plt. figure( )
ax1= fig. add_subplot( 221 )
ax2= fig. add_subplot( 222 )
ax3= fig. add_subplot( 223 )
ax4= fig. add_subplot( 224 )
ax1. plot( x, x)
ax2. plot( x, x** 2 / 100 )
ax3. plot( x, - x)
ax4. plot( x, np. log( x) )
plt. show( )
创建多图
fig1= plt. figure( )
ax1= fig1. add_subplot( 111 )
ax1. plot( [ 1 , 2 , 3 ] , [ 3 , 2 , 1 ] )
fig2= plt. figure( )
ax2= fig2. add_subplot( 111 )
ax2. plot( [ 1 , 2 , 3 ] , [ 1 , 2 , 3 ] )
plt. show( )
网格视图
y= np. arange( 1 , 5 )
plt. plot( y, y* 2 , 'r' )
plt. grid( True )
plt. title( 'plt' )
plt. grid( color= 'k' , linewidth= '0.5' , linestyle= '-.' )
plt. show( )
x= np. arange( 0 , 10 , 1 )
fig= plt. figure( figsize= ( 16 , 8 ) , dpi= 128 )
ax= fig. add_subplot( 111 )
plt. plot( x, x** 2 , 'c' )
ax. grid( color= 'g' , linewidth= '0.5' , linestyle= '--' )
plt. show( )
添加图例legend
参数 释义 loc 位置 0 best 1 upper right 2 upper left 3 lower left 4 lower right 5 right 6 center left 7 center right 8 lower center 9 upper center 10 center ncol 图例列数
x= np. arange( 2 , 22 , 1 )
fig= plt. figure( )
ax= fig. add_subplot( 111 )
l, = plt. plot( x, x)
l, = plt. plot( x, x** 2 , label= 'label via plot' )
ax. legend( )
plt. show( )
调整坐标轴范围
x= np. arange( - 10 , 11 , 1 )
plt. plot( x, x** 2 )
plt. axis( [ - 5 , 5 , 0 , 50 ] )
plt. xlim( [ - 7 , 7 ] )
plt. ylim( [ 0 , 100 ] )
plt. xlim( xmin= - 9 )
plt. ylim( ymax= 80 )
plt. show( )
调整坐标轴刻度
'''14.调整坐标轴刻度'''
import numpy as np
import matplotlib. pyplot as plt
import datetime
import matplotlib as mpl
'''1.面向对象方式---调整坐标轴刻度'''
x= np. arange( 1 , 11 , 1 )
plt. plot( x, x)
'''获取当前图形的坐标轴'''
ax= plt. gca( )
'''设置刻度有多少格
只调整x/y轴'''
ax. locator_params( 'x' , nbins= 20 )
ax. locator_params( 'y' , nbins= 10 )
'''2.plt实时交互--调整坐标轴刻度'''
plt. locator_params( 'x' , nbins= 5 )
plt. show( )
面向对象调整日期刻度
fig= plt. figure( )
start= datetime. datetime( 2019 , 1 , 1 )
stop= datetime. datetime( 2020 , 1 , 1 )
delta= datetime. timedelta( days= 1 )
'''生成dates数列'''
dates= mpl. dates. drange( start, stop, delta)
'''生成dates长度的随机数列'''
y= np. random. rand( len ( dates) )
ax= plt. gca( )
ax. plot_date( dates, y, linestyle= '-' , marker= '' )
'''调整格式--其实已经自动调整好了'''
date_format= mpl. dates. DateFormatter( '%Y-%m-%d' )
ax. xaxis. set_major_formatter( date_format)
'''调整重叠,自适应调节'''
fig. autofmt_xdate( )
plt. show( )
添加另一个坐标轴
x= np. arange( 1 , 21 , 1 )
y1= x* x
y2= np. log( x)
'''1.pyplot方式'''
'''两个y轴'''
plt. plot( x, y1, 'orange' )
plt. twinx( )
plt. plot( x, y2, 'r' )
plt. show( )
'''两个x轴'''
添加注释
x= np. arange( - 10 , 11 , 1 )
y= x** 2
plt. plot( x, y)
plt. annotate( 'this is the bottom' , xy= ( 0 , 1 ) , xytext= ( - 2.5 , 20 ) ,
arrowprops= dict ( facecolor= 'orange' , headlength= 10 ,
headwidth= 10 , width= 5 ) )
plt. show( )
添加文字标注
x= np. arange( - 10 , 11 , 1 )
y= x** 2
plt. plot( x, y)
'''坐标,文字内容,字体,大小,颜色,样式,粗细,阴影'''
plt. text( - 2.5 , 60 ,
'function:y=x*x' ,
family= 'serif' ,
size= 20 ,
color= 'orange' ,
style= 'normal' ,
weight= 'black' ,
bbox= dict ( facecolor= 'r' , alpha= 0.1 ) )
plt. text( - 2.5 , 80 ,
'function:y=x*x' ,
family= 'fantasy' ,
size= 20 ,
color= 'green' ,
style= 'italic' ,
weight= 'light' ,
bbox= dict ( facecolor= 'b' , alpha= 0.1 ) )
plt. show( )
使用Tex公式写出数学公式
import matplotlib. pyplot as plt
fig= plt. figure( )
ax= fig. add_subplot( 111 )
ax. set_xlim( [ 1 , 7 ] )
ax. set_ylim( [ 1 , 5 ] )
ax. text( 2 , 4 , r"$ \alpha_i \beta_i \pi \lambda \omega $" , size= 15 )
ax. text( 4 , 4 , r"$ \sin(0)=\cos(\frac{\pi}{2}) $" , size= 15 )
ax. text( 2 , 2 , r"$ \lim_{x \rightarrow y} \frac{1}{x^3} $" , size= 15 )
ax. text( 4 , 2 , r"$ \sqrt[4]{x}=\sqrt{y} $" , size= 15 )
plt. show( )
区域填充
x= np. linspace( 0 , 5 * np. pi, 100 )
y1= np. sin( x)
y2= np. sin( 2 * x)
plt. fill( x, y1, 'blue' , alpha= 0.3 )
plt. fill( x, y2, 'red' , alpha= 0.3 )
fig= plt. figure( )
ax= plt. gca( )
ax. plot( x, y1, color= 'g' , linewidth= 0.5 )
ax. plot( x, y2, color= 'b' , linewidth= 0.5 )
ax. fill_between( x, y1, y2, where= y1> y2, facecolor= 'g' , alpha= 0.3 , interpolate= True )
ax. fill_between( x, y1, y2, where= y1< y2, facecolor= 'b' , alpha= 0.3 , interpolate= True )
plt. show( )
绘制形状
import numpy as np
import matplotlib. pyplot as plt
import matplotlib. patches as mpatches
'''绘制填充好的图形'''
fig, ax= plt. subplots( )
'''1.圆形'''
xy1= np. array( [ 0.2 , 0.2 ] )
circle= mpatches. Circle( xy1, radius= 0.1 )
ax. add_patch( circle)
'''2.长方形'''
xy2= np. array( [ 0.1 , 0.5 ] )
rect= mpatches. Rectangle( xy2, width= 0.2 , height= 0.1 , color= 'orange' )
ax. add_patch( rect)
'''3.多边形'''
xy3= np. array( [ 0.6 , 0.2 ] )
polygon= mpatches. RegularPolygon( xy3, numVertices= 5 , radius= 0.1 , color= 'g' )
ax. add_patch( polygon)
'''4.椭圆'''
xy4= np. array( [ 0.6 , 0.55 ] )
ellipse= mpatches. Ellipse( xy4, width= 0.2 , height= 0.1 , color= 'y' )
ax. add_patch( ellipse)
plt. axis( 'equal' )
plt. grid( )
plt. show( )
美化图形
import numpy as np
import matplotlib. pyplot as plt
'''样式
dark_background
bmh
grayscale
ggplot
fivethirtyeight'''
plt. style. use( 'ggplot' )
fig, axes= plt. subplots( ncols= 2 , nrows= 2 )
ax1, ax2, ax3, ax4= axes. ravel( )
x, y= np. random. normal( size= ( 2 , 100 ) )
ax1. plot( x, y, 'o' )
x= np. arange( 0 , 10 )
y= np. arange( 0 , 10 )
'''默认颜色的循环'''
colors= [ 'g' , 'b' , 'orange' , 'cyan' , 'red' , 'k' , 'y' ]
ncolors= len ( colors)
shift= np. linspace( 0 , 10 , ncolors)
for s in shift:
ax2. plot( x, y+ s, '-' )
x= np. arange( 5 )
y1, y2, y3= np. random. randint( 1 , 25 , size= ( 3 , 5 ) )
width= 0.25
ax3. bar( x, y1, width)
ax3. bar( x+ width, y2, width)
ax3. bar( x+ 2 * width, y3, width)
for i, color in enumerate ( colors) :
xy= np. random. normal( size= 2 )
ax4. add_patch( plt. Circle( xy, radius= 0.2 , color= color) )
ax4. axis( 'equal' )
plt. show( )
极坐标
import numpy as np
import matplotlib. pyplot as plt
'''1'''
r1= np. arange( 1 , 6 , 1 )
theta= [ 0 , np. pi/ 2 , np. pi, 3 * np. pi/ 2 , 2 * np. pi]
'''投影成极坐标'''
ax1= plt. subplot( 111 , projection= 'polar' )
ax1. plot( theta, r1, color= 'red' , linewidth= 2 )
ax1. grid( True )
'''2.四边形'''
r2= np. empty( 5 )
r2. fill( 5 )
ax2= plt. subplot( 111 , projection= 'polar' )
ax2. plot( theta, r2, color= 'g' , linewidth= 2 )
'''3.八边形'''
r3= np. empty( 9 )
r3. fill( 5 )
twopi= 2 * np. pi
theta1= [ 0 , twopi/ 8 , 2 * twopi/ 8 , 3 * twopi/ 8 , 4 * twopi/ 8 ,
5 * twopi/ 8 , 6 * twopi/ 8 , 7 * twopi/ 8 , 8 * twopi/ 8 ]
ax3= plt. subplot( 111 , projection= 'polar' )
ax3. plot( theta1, r3, color= 'orange' , linewidth= 2 )
plt. show( )
函数积分图实例
import numpy as np
import matplotlib. pyplot as plt
from matplotlib. patches import Polygon
def func ( x) :
return - ( x- 2 ) * ( x- 8 ) + 40
x= np. linspace( 0 , 10 )
y= func( x)
fig, ax= plt. subplots( )
plt. plot( x, y, 'r' , linewidth= 2 )
a= 2
b= 9
'''取消刻度显示'''
ax. set_xticks( [ a, b] )
ax. set_yticks( [ ] )
ax. set_xticklabels( [ '$a$' , '$b$' ] )
'''设置坐标轴名称'''
plt. figtext( 0.9 , 0.06 , '$x$' , size= 14 )
plt. figtext( 0.1 , 0.9 , '$y$' , size= 14 )
'''生产多边形的点'''
ix= np. linspace( a, b)
iy= func( ix)
ixy= zip ( ix, iy)
'''绘制函数下阴影'''
verts= [ ( a, 0 ) ] + list ( ixy) + [ ( b, 0 ) ]
poly= Polygon( verts, facecolor= '0.7' , edgecolor= '0.5' )
ax. add_patch( poly)
'''添加函数表达式'''
x_math= ( a+ b) * 0.5
y_math= 35
plt. text( x_math, y_math, r"$ \int_a^b (-(x+2)*(2*x-8)+60)dx $" ,
size= 12 , horizontalalignment= 'center' )
'''调小y轴'''
plt. ylim( ymin= 25 )
plt. show( )
散点条形图
import numpy as np
import matplotlib. pyplot as plt
plt. style. use( 'ggplot' )
x= np. random. randn( 200 )
y= x+ np. random. randn( 200 ) * 0.5
'''边界构图值'''
margin_border= 0.1
width= 0.6
margin_between= 0.02
height= 0.2
'''主散点图画布参数'''
left_s= margin_border
bottom_s= margin_border
width_s= width
height_s= width
'''上方直方图画布参数'''
left_x= margin_border
bottom_x= margin_border+ width+ margin_between
width_x= width
height_x= height
'''右方直方图画布参数'''
left_y= margin_border+ width+ margin_between
bottom_y= margin_border
width_y= height
height_y= width
'''绘制底图'''
plt. figure( 1 , figsize= ( 8 , 8 ) )
rect_s= [ left_s, bottom_s, width_s, height_s]
rect_x= [ left_x, bottom_x, width_x, height_x]
rect_y= [ left_y, bottom_y, width_y, height_y]
axScatter= plt. axes( rect_s)
axHisX= plt. axes( rect_x)
axHisY= plt. axes( rect_y)
'''去掉附图标签'''
axHisX. set_xticks( [ ] )
axHisY. set_yticks( [ ] )
'''绘图'''
axScatter. scatter( x, y, s= 10 )
bin_width= 0.25
xymax= np. max ( [ np. max ( np. fabs( x) ) , np. max ( np. fabs( y) ) ] )
lim= int ( xymax/ bin_width+ 2 ) * bin_width
axScatter. set_xlim( - lim, lim)
axScatter. set_ylim( - lim, lim)
bins= np. arange( - lim, lim+ bin_width, bin_width)
axHisX. hist( x, bins= bins, color= 'green' , edgecolor= 'white' , alpha= 0.7 )
axHisY. hist( y, bins= bins, color= 'orange' ,
edgecolor= 'white' , orientation= 'horizontal' )
axHisX. set_xlim( axScatter. get_xlim( ) )
axHisY. set_ylim( axScatter. get_xlim( ) )
plt. title( 'Scatter and Hist' )
plt. show( )
球员能力雷达图
import numpy as np
import matplotlib. pyplot as plt
plt. style. use( 'ggplot' )
'''显示中文和显示负号'''
plt. rcParams[ 'font.sans-serif' ] = [ 'SimHei' ]
plt. rcParams[ 'axes.unicode_minus' ] = False
ax1= plt. subplot( 221 , projection= 'polar' )
ax2= plt. subplot( 222 , projection= 'polar' )
ax3= plt. subplot( 223 , projection= 'polar' )
ax4= plt. subplot( 224 , projection= 'polar' )
'''能力标签'''
ability_label= [ '进攻' , '防守' , '盘带' , '速度' , '体力' , '射术' ]
ability_size= 6
player= {
'M' : np. random. randint( size= ability_size, low= 60 , high= 99 ) ,
'H' : np. random. randint( size= ability_size, low= 60 , high= 99 ) ,
'P' : np. random. randint( size= ability_size, low= 60 , high= 99 ) ,
'Q' : np. random. randint( size= ability_size, low= 60 , high= 99 )
}
theta= np. linspace( 0 , 2 * np. pi, 6 , endpoint= False )
theta= np. append( theta, theta[ 0 ] )
player[ 'M' ] = np. append( player[ 'M' ] , player[ 'M' ] [ 0 ] )
player[ 'H' ] = np. append( player[ 'H' ] , player[ 'H' ] [ 0 ] )
player[ 'P' ] = np. append( player[ 'P' ] , player[ 'P' ] [ 0 ] )
player[ 'Q' ] = np. append( player[ 'Q' ] , player[ 'Q' ] [ 0 ] )
'''绘制梅西能力图'''
ax1. plot( theta, player[ 'M' ] , 'r' , linewidth= 1 )
ax1. fill( theta, player[ 'M' ] , 'r' , alpha= 0.5 )
ax1. set_xticks( theta)
ax1. set_xticklabels( ability_label)
ax1. set_title( '梅西' , color= 'r' , position= ( 0.5 , 0.99 ) )
ax1. set_yticks( [ 20 , 40 , 60 , 80 , 100 ] )
'''绘制哈维能力图'''
ax2. plot( theta, player[ 'H' ] , 'g' , linewidth= 1 )
ax2. fill( theta, player[ 'H' ] , 'g' , alpha= 0.5 )
ax2. set_xticks( theta)
ax2. set_xticklabels( ability_label)
ax2. set_title( '哈维' , color= 'g' , position= ( 0.5 , 0.99 ) )
ax2. set_yticks( [ 20 , 40 , 60 , 80 , 100 ] )
'''绘制皮克能力图'''
ax3. plot( theta, player[ 'P' ] , 'b' , linewidth= 1 )
ax3. fill( theta, player[ 'P' ] , 'b' , alpha= 0.5 )
ax3. set_xticks( theta)
ax3. set_xticklabels( ability_label)
ax3. set_title( '皮克' , color= 'b' , position= ( 0.5 , 0.99 ) )
ax3. set_yticks( [ 20 , 40 , 60 , 80 , 100 ] )
'''绘制切赫能力图'''
ax4. plot( theta, player[ 'Q' ] , 'y' , linewidth= 1 )
ax4. fill( theta, player[ 'Q' ] , 'y' , alpha= 0.5 )
ax4. set_xticks( theta)
ax4. set_xticklabels( ability_label)
ax4. set_title( '切赫' , color= 'y' , position= ( 0.5 , 0.99 ) )
ax4. set_yticks( [ 20 , 40 , 60 , 80 , 100 ] )
plt. show( )
其他可视化库
库名 介绍 Seaborn Seaborn是基于matplotlib产生的一个模块,专攻于统计可视化,可以和pandas进行无缝链接,使初学者更容易上手。相对于matplotlib,Seaborn语法更简洁,两者关系类似于numpy和pandas之间的关系。 HoloViews HoloViews是一个开源的Python库,可以用非常少的代码行中完成数据分析和可视化,除了默认的matplotlib后端外,还添加了一个Bokeh后端。Bokeh提供了一个强大的平台,通过结合Bokeh提供的交互式小部件,可以使用HTML5 canvas和WebGL快速生成交互性和高维可视化,非常适合于数据的交互式探索。 Altair Altair是Python的一个公认的统计可视化库。它的API简单、友好、一致,并建立在强大的vega - lite(交互式图形语法)之上。Altair API不包含实际的可视化呈现代码,而是按照vega - lite规范发出JSON数据结构。由此产生的数据可以在用户界面中呈现,这种优雅的简单性产生了漂亮且有效的可视化效果,且只需很少的代码。 PyQtGraph PyQtGraph是在PyQt4 / PySide和numpy上构建的纯 python的GUI图形库。它主要用于数学,科学,工程领域。尽管PyQtGraph完全是在python中编写的,但它本身就是一个非常有能力的图形系统,可以进行大量的数据处理,数字运算;使用了Qt的GraphicsView框架优化和简化了工作流程,实现以最少的工作量完成数据可视化,且速度也非常快。 ggplot ggplot是基于R的ggplot2和图形语法的Python的绘图系统,实现了更少的代码绘制更专业的图形。 它使用一个高级且富有表现力的API来实现线,点等元素的添加,颜色的更改等不同类型的可视化组件的组合或添加,而不需要重复使用相同的代码,然而这对那些试图进行高度定制的的来说,ggplot并不是最好的选择,尽管它也可以制作一些非常复杂、好看的图形。 Bokeh Bokeh是一个Python交互式可视化库,支持现代化web浏览器展示(图表可以输出为JSON对象,HTML文档或者可交互的网络应用)。它提供风格优雅、简洁的D3.js的图形化样式,并将此功能扩展到高性能交互的数据集,数据流上。使用Bokeh可以快速便捷地创建交互式绘图、仪表板和数据应用程序等。 pygal pygal是一种开放标准的矢量图形语言,它基于XML(Extensible Markup Language),可以生成多个输出格式的高分辨率Web图形页面,还支持给定数据的html表导出。用户可以直接用代码来描绘图像,可以用任何文字处理工具打开SVG图像,通过改变部分代码来使图像具有交互功能,并且可以插入到HTML中通过浏览器来观看。 VisPy VisPy是一个用于交互式科学可视化的Python库,快速、可伸缩、且易于使用,是一个高性能的交互式2维, 3维数据可视化库,利用了现代图形处理单元(gpu)的计算能力,通过OpenGL库来显示非常大的数据集。 NetworkX NetworkX是一个Python包,用于创建、操纵和研究复杂网络的结构、以及学习复杂网络的结构、功能及其动力学。