Matplotlib figures are not redrawn in the cell in which they are created
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- jupyter-notebook, matplotlib, python
调研方向
首先,在 JupyterLab 或 Notebook 中使用 %matplotlib widget 后端运行提供的同一单元格复现,然后将其与分离单元格版本进行比较。完成标准是:fig.canvas.draw() 会在每次循环迭代期间明显更新图形,而不是仅在循环结束后更新。
由索引模型根据 Issue 内容生成。
描述
Describe the issue
Using an interactive figure's canvas.draw() method does not update the figure if it was created in the same cell as the draw call.
Figure created in the same cell:

Figure created in another cell:

Reproduce
- Open a new notebook in JupyterLab or Notebook
- Insert the following code:
import matplotlib.pyplot as plt
import time
%matplotlib widget
fig = plt.figure()
for i in range(5):
x = list(range(i+2))
xx = [x**2 for x in x]
plt.clf()
plt.plot(x, xx)
fig.canvas.draw()
time.sleep(1)
- Run the cell and observe that the plot does not show until the loop has exited.
Optional:
- Move the for loop to a separate cell from the figure creation
- Run cell and observe plot updates during the loop
This can be reproduced using the scipy notebook docker stack.
Versions
3.8.5 | packaged by conda-forge | (default, Jul 31 2020, 02:39:48)
[GCC 7.5.0]
ipympl version: 0.5.7
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : not installed
ipython : 7.17.0
ipykernel : 5.3.4
jupyter client : 6.1.6
jupyter lab : 2.1.5
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.7
traitlets : 4.3.3
Known nbextensions:
config dir: /opt/conda/etc/jupyter/nbconfig
notebook section
jupyter-matplotlib/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
JupyterLab v2.1.5
Known labextensions:
app dir: /opt/conda/share/jupyter/lab
@bokeh/jupyter_bokeh v2.0.3 enabled OK
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK
jupyter-matplotlib v0.7.3 enabled OK
- 主要语言
- Jupyter Notebook
- 星标
- 1.7k
- 派生
- 234
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
matplotlib/ipympl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
matplotlib/ipympl#623 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
matplotlib/ipympl#622 · 13 条评论 ·
-
难度 4/5 3-5 天 新手友好度 42/100
matplotlib/ipympl#612 ·
-
难度 3/5 1-2 天 新手友好度 45/100
matplotlib/ipympl#611 · 4 条评论 ·
-
难度 4/5 3-5 天 新手友好度 42/100
matplotlib/ipympl#609 · 7 条评论 ·
查看 matplotlib/ipympl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 90/100
droidconKE/droidconKE2022Web#167 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
PedestrianDynamics/pyFDS-Evac#228 ·
维护者通常 1 天内回复
-
scope: charts status: waiting for maintainer
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 2 天内回复
-
type/bug
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 1 天内回复
-
.Needs Triage .Team/UXWest Priority:P2 Type:Bug
难度 2/5 1-3 小时 新手友好度 86/100
metabase/metabase#83085 · 1 条评论 ·
维护者通常 1 天内回复