matplotlib / matplotlib/ipympl
Using ipympl logic inside python shell or ipython?
まだ誰も着手していません。
- 主要言語
- Jupyter Notebook
- スター
- 1.7k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I have a class that inherits from the `ipywidgets.widgets.VBox` and adds a `figure.canvas` instance of a matplotlib figure to its children like so:
```python
import matplotlib.pyplot as plt
from ipywidgets import widgets
plt.ioff()
class MyVis(widgets.VBox):
def __init__(self):
super().__init__()
self.fig = plt.figure()
self.children = [self.fig.canvas]
m = MyVis()
```
This works fine when I use this class within jupyter notebooks using the `%matplotlib widget` magic before executing the above code.
When executed within ipython I get
`TraitError: Element of the 'children' trait of a MyVis instance must be a Widget, but a value of was specified.`
since of course `ipympl` and its magic are not active.
Since I also want to have unit-tests for this class (and others that make use of this class) using `pytest`, it would be nice to get around this problem.
Can I enable the `ipympl` way of handling figures somehow in the python shell (similar to using the `%matplotlib widget` magic in the notebook) that would allow my tests to run?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
MyVis の例から始めて、IPython で TraitError を再現し、その後、`%matplotlib widget` マジックを使用するノートブックのセットアップと比較します。matplotlib の canvas がどのように選択されているかを確認し、pytest のテストケースが Jupyter 外で互換性のある widget canvas を使用できるようにするテストセットアップを特定します。クラスを Tk canvas エラーなしでインスタンス化してテストできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- jupyter, python
- 領域
- backend, testing
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 28/100