Nesting into HBox collapses plot width

Open
#125 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
jupyter-notebook, matplotlib, python
Domain
frontend

Research direction

Start with the provided Canvas/FigureManager reproducer in a notebook, comparing a canvas in one HBox with the same canvas nested in two HBoxes. Investigate how the canvas size is propagated to ipywidgets layouts; done means the plot keeps its width when nested without explicitly setting canvas.layout.width.

Written by the indexing model from the issue text.

Description

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])


Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from matplotlib/ipympl

All issues in matplotlib/ipympl

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.