matplotlib / matplotlib/ipympl
Nesting into HBox collapses plot width
还没有人认领这个 Issue。
- 主要语言
- Jupyter Notebook
- 星标
- 1.7k
- 派生
- 234
- PR 合并指标
- 30 天内没有已合并 PR
描述
Here's another effect of requiring the canvas size explicitly, but somehow isn't visible unless the plot gets dropped into an ipywidgets layout (e.g. by a downstream package).
If the interactive matplotlib is the child of one p-Panel, it's fine. But gets squashed as the child of two p-Panels (regardless of orientation).
Explicitly setting canvas.layout.width fixes it, and propagates to the front-end as expected.
```
from ipywidgets import HTML, HBox, VBox
from matplotlib.figure import Figure
from ipympl.backend_nbagg import Canvas, FigureManager
figure = Figure()
canvas = Canvas(figure)
canvas.manager = FigureManager(canvas, 0)
axes = figure.add_subplot(1,1,1)
HBox([HBox([HTML(''), canvas])])
```
```
HBox([canvas])
```


贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 notebook 中从提供的 Canvas/FigureManager 复现器开始,将一个位于单个 HBox 中的 canvas 与同一个嵌套在两个 HBoxes 中的 canvas 进行比较。调查 canvas 大小如何传播到 ipywidgets 布局;完成标准是:在未显式设置 canvas.layout.width 的情况下,图表在嵌套后仍保持其宽度。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- jupyter-notebook, matplotlib, python
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100