はじめに
jupyter notebookの対話的にパラメータを調整できる機能(ipywidgets RadioButtons, IntSlider)でデータを取得する方向を選択し、3Dグラフ上の任意の位置のデータを線で表示する方法について説明する。
コード

解説
このコードは下記の投稿のコードを改変したものとなっている。そのため、変更点のみを解説する。

[ipywidgets] 6. RadioButtonsでデータを取得する方向を選択して、IntSliderで画像の任意の位置のデータをラインで表示
jupyter notebookの対話的にパラメータを調整できる機能(ipywidgets RadioButtons, IntSlider)でデータを取得する方向を選択し、画像中の任意の位置のデータを線で表示する方法について説明する。
3Dグラフの設定
plot_surfaceでデータを表示する。axhline, axvlineは使わずに通常のplotでラインを表示する。
ipywidgetsの設定
3Dグラフのデータをセットするので、set_zdata()だと思われたが、set_3d_properties()でzデータをセットする。
ラジオボタンをyにしたときの図

参考
Jupyter Widgets — Jupyter Widgets 8.1.5 documentation
コメント