matplotlib / matplotlib/ipympl

display `print` in callbacks in the notebook

オープン
#116 コメント 8 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Jupyter Notebook
スター
1.7k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
n = 0

def printer(event):
    global n
    print(f'in event {event}')
    n += 1
 

fig.canvas.mpl_connect('button_press_event', printer)

when run in IPython prints out to stdout on every mouse click. In jlab + ipympl the prints don't show up anywhere I can find...

From https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html it looks like this can work via:

output = widgets.Output()
display(fig.canvas, output)

n = 0
def printer(event):
    global n
    with output:
        print(f'in event {event}')
    n += 1
    
fig.canvas.mpl_connect('button_press_event', printer)

but I suspect there is a way for this to work automatically....

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

この issue では、fig.canvas.mpl_connect を使用する Python コールバックと、ipywidgets.Output を使った回避策が示されています。まず、ipympl を使用して JupyterLab で不足している print 出力を再現し、IPython と比較します。コールバックを Output コンテキストでラップしなくても、matplotlib のコールバックからの print 出力がノートブックに自動的に表示されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
jupyter, jupyter-notebook, python
領域
data-visualization, frontend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。