jupyter lab安装ipympl提供matplotlib交互式后端

jupyter lab安装ipympl提供matplotlib交互式后端

概述

在Jupyter Notebook或Jupyter Lab环境中运行以下代码可知

import matplotlib
print(matplotlib.get_backend())

Jupyter环境的默认后端为module://ipykernel.pylab.backend_inline。
默认情况下,使用默认后端,matplotlib在Jupyter环境即便开启了交互绘图模式,也不能正常实现交互式绘图。

如果在Jupyter环境中实现matplotlib交互式绘图,必须使用Matplotlib Jupyter Widget Backend,即ipympl包(原名:jupyter-matplotlib)。

ipympl包是matplotlib开发组专门为Jupyter环境开发的交互式后端,利用Jupyter Widget 实现功能,项目地址为 https://github.com/matplotlib/ipympl

使用ipympl

安装
使用pip或conda进行安装。
pip install ipympl

基本使用
安装完ipympl,切记要重启Jupyter Notebook或Jupyter Lab服务。
在jupyter中执行魔术命令%matplotlib widget将后端切换为ipympl。

%matplotlib widget
import matplotlib
matplotlib.ge
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值