Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

automatic widget resizing for reactive design

未关闭
#297 3 条评论 10 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, jupyter, jupyter-notebook

调研方向

从 mpl_widgets.js 开始,在 Jupyter notebook 的 ipywidgets.Output 中使用 matplotlib widget 重现该问题。检查 jupyter-matplotlib-canvas-container 和 jupyter-matplotlib-canvas-div 在浏览器调整大小期间如何接收其宽度。完成的标准是:窗口大小发生变化时,canvas 会跟随其父 widget,而无需手动拖动 resize handle。

由索引模型根据 Issue 内容生成。

描述

enhancement

Describe the issue

The matplotlib widget (matplotlib widgets - ipywidgets.Output()) cannot be made reactive to browser window resizing in jupyter notebooks.

Setting the canvas style properties as recomended, i.e.
fig.canvas.layout.min_width = '400px'
fig.canvas.layout.flex='1 1 auto'
fig.canvas.layout.width = 'auto'

makes the parent widget-vbox reactive, but the actual canvas jupyter-matplotlib-canvas-container and jupyter-matplotlib-canvas-div are set to a fixed width. This width seems to only be controllably by explicitly setting a width at the time of figure creation or by manually dragging the resizing handle.
The code to resize the canvas is there in mpl_widgets.js ; It just seems not to be possible to make the canvas container react to a window size change.

Paloha describes the issue more comprehensively:
https://stackoverflow.com/questions/61272384/how-to-resize-matplotlib-figure-to-match-ipywidgets-output-size-automatically

Versions

 3.8.6 | packaged by conda-forge | (default, Dec 26 2020, 05:05:16) 
[GCC 9.3.0]
ipympl version: 0.6.3
jupyter core     : 4.7.0
jupyter-notebook : 6.2.0
qtconsole        : not installed
ipython          : 7.19.0
ipykernel        : 5.4.2
jupyter client   : 6.1.11
jupyter lab      : 2.2.9
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5
Known nbextensions:
  config dir: /opt/conda/etc/jupyter/nbconfig
    notebook section
      jupyter-datawidgets/extension  enabled 
      - Validating: OK
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyter-threejs/extension  enabled 
      - Validating: OK
      jupyter_dash/main  enabled 
      - Validating: OK
      nbdime/index  enabled 
      - Validating: OK
      plotlywidget/extension  enabled 
      - Validating: OK
      voila/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      appmode/main  enabled 
      - Validating: OK
      nbextensions_configurator/config_menu/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/config_menu/main
    tree section
      jupyter_server_proxy/tree  enabled 
      - Validating: OK
      nbextensions_configurator/tree_tab/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/tree_tab/main
JupyterLab v2.2.9
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @bokeh/jupyter_bokeh v2.0.4  enabled  OK
        @jupyter-voila/jupyterlab-preview v1.1.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyterlab/git v0.23.3  enabled  OK
        @jupyterlab/latex v2.0.1  enabled  OK
        @jupyterlab/plotly-extension v1.0.0  enabled   X
        @jupyterlab/toc v4.0.0  enabled  OK
        @jupyterlab/vega3-extension v2.0.0  enabled  OK
        jupyter-threejs v2.2.0  enabled  OK
        jupyterlab-dash v0.4.0  enabled  OK
        jupyterlab-datawidgets v7.0.0  enabled  OK
        jupyterlab-kernelspy v2.2.0  enabled  OK
        jupyterlab_variableinspector v0.1.0  enabled   X
        nbdime-jupyterlab v2.0.1  enabled  OK
        plotlywidget v4.14.3  enabled  OK

   The following extension are outdated:
        @jupyterlab/plotly-extension
        jupyterlab_variableinspector
        
   Consider running "jupyter labextension update --all" to check for updates.

主要语言
Jupyter Notebook
星标
1.7k
派生
234
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

matplotlib/ipympl 的其他 Issue

查看 matplotlib/ipympl 的全部 Issue

相似的 Issue

更多 Data Visualization Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。