matplotlib / matplotlib/ipympl
Layout Templates and matplotlib figures
まだ誰も着手していません。
- 主要言語
- Jupyter Notebook
- スター
- 1.7k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
see #117 (issue) and #174 (PR) for some discussion on the topic.
@martinRenou I have been playing with using [Layout Templates](https://ipywidgets.readthedocs.io/en/latest/examples/Layout%20Templates.html) to stack figures in fun ways. Unfortunately, since matplotlib is currently responsible for the figure size, I end up with situations such as the following, where the figures are all cut off a bit. This is particularly noticable in `jupyter notebook` since the screen width is reduced.
In the following example, I stack a 4x4 of buttons and then a 4x4 of figures. The buttons stretch nicely, but the figures do not.
```python
%matplotlib widget
import matplotlib.pyplot as plt
from ipywidgets import TwoByTwoLayout
from ipywidgets.widgets import Button, Layout
# Buttons
def button(name):
return Button(description = name, layout=Layout(height='auto', width='auto'))
a,b,c,d = button("1"), button("2"), button("3"), button("4"),
layout_2x2 = TwoByTwoLayout(top_left=a,
top_right=b,
bottom_left=c,
bottom_right=d)
display(layout_2x2)
# Figures
figs = []
plt.ioff()
for i in range(4):
fig, ax = plt.subplots()
ax.imshow([[1,2], [3,4]])
figs.append(fig.canvas)
a,b,c,d = figs
layout_2x2 = TwoByTwoLayout(top_left=a,
top_right=b,
bottom_left=c,
bottom_right=d)
display(layout_2x2)
```

In `jupyter lab` the problem is less so, but still unfortunate that figures basically ignore the flexbox layout the widgets are designed with. I would set the size with matplotlib, but since I don't know the size of the viewport the user is using, it's likely that the size I choose will be too small or too large depending on the user.
I don't have a concrete solution at hand, but I'm wondering if we can come up with some logic that preserves aspect ratio but otherwise fills a widget to its fullest extent?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue にある Layout Templates の例を Jupyter Notebook と JupyterLab で再現し、次に #117 の議論と #174 の既存の作業を確認してください。望ましい結果はまだ定義されていません。matplotlib の Figure がアスペクト比を維持しながら widget layout を埋められるようにするアプローチを明確にし、そのうえで動作をどのように検証すべきかを決めてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- jupyter-notebook, matplotlib
- 領域
- frontend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100