背景
jupyterlab + matplotlib でプロット図や画像から, マウス位置のピクセル値などを取得したい
方法
pick event を使います.
https://matplotlib.org/3.1.1/gallery/event_handling/pick_event_demo.html
pip などで ipympl
を入れておきます.
https://stackoverflow.com/questions/50149562/jupyterlab-interactive-plot
を参考に, Jupyterlab の interactive widget 機能(?)を有効にします.
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
jupyter nbextension enable --py widgetsnbextension
%matplitlib widget
を notebook の最初に記述しておきます.
サンプルコード
https://matplotlib.org/3.1.1/gallery/event_handling/pick_event_demo.html
を動かして, うまくいけば成功です!