本文分享一个Python交互式可视化工具bqplot,bqplot是为Jupyter Notebook开发的一个交互插件,使用图层图形语法 (the Grammar of Graphics
,了解该语法👉图层图形语法详解) ,但是丰富了交互图层,可满足丰富的交互式可视化需求,比如,
神经网络交互可视化
时间序列交互可视化
此外,在基础图形可视化上,bqplot功能也很强大,拥有类似matplotlib.pyplot
的bqplot.pyplo
t。
安装
pip install bqplot
jupyter nbextension enable --py --sys-prefix bqplot
安装成功后,在Jupyter Notebook主页会出现👇
快速使用
bqplot有两种实现可视化的方式
- 面向对象方法: 使用图层图形语法 (
the Grammar of Graphics
) ,可满足更多个性化需求; - pyplot方法: 即
bqplot.pyplot
,类似matplotlib.pyplot; - 下面简单列举两个例子,
非交互图形
主要使用bqplot.pyplot实现,以bqplot.pyplot.hist为例,
import numpy as np
import bqplot.pyplot as plt
fig = plt.figure(title='Histogram by bqplot')
hist = plt.hist(sample=np.random.randn(100), bins=10, colors=['#01a2d9'])
fig
交互图形
在图形中实现平移、缩放、选择等交互功能,
气泡图交互可视化
更多移步:https://github.com/bqplot/bqplot
-END-