matplotlib / matplotlib/ipympl
Displaying a previously created Matplotlib figure in a widget
还没有人认领这个 Issue。
- 主要语言
- Jupyter Notebook
- 星标
- 1.7k
- 派生
- 234
- PR 合并指标
- 30 天内没有已合并 PR
描述
I'm trying to find a way to take a figure previously created, and show it inside a widget, without losing interactivity.
Here's a short version of my approach (which may not be the right one):
fig = plt.figure() # previously created figure
out = widgets.Output()
with out:
display(fig)
# other things happening
display(widgets.HBox([fig.canvas, some_other_fig]))
If I first create a figure in the notebook outside of an Output widget, and then wish to include it later inside something like an HBox next to a second figure, I seem to lose interactivity with the figure (including the nice ipympl zoom interface).
Here is a nbviewer view of a MWE notebook I created, download it top right on the window. It's best if one downloads it and runs it since the first figure appears buggy in the nbviewer.
Additionally, and I might create a new issue for this - if I call fig1 at the end of the notebook, I get an unexpected error. Here I'd expect the regular figure to be shown. The error is AttributeError: 'NoneType' object has no attribute '_send_event'.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
下载并运行链接的 Output Example Notebook,以使用之前创建的 figure、Output widget 和 HBox 重现该行为。首先跟踪所显示的 figure 及其 canvas 是如何处理的,然后验证 figure 在 HBox 中仍保留 ipympl 交互性,并确认显示 fig1 不再引发所报告的 NoneType 错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- jupyter-notebook, matplotlib, python
- 领域
- data-visualization, frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100