はじめに
jupyter notebookの対話的にパラメータを選択できる機能(ipywidgets IntSlider)で、3Dグラフの視点をインタラクティブに変更する方法について説明する。
コード

解説
モジュールのインポートなど
3Dグラフの作成
用いる3Dグラフは下記記事を基に作成した。

[matplotlib 3D] 56. voxelグラフでRGB cube
matplotlib mplot3dの3DボクセルグラフでRGB色空間を表示する。
ipywidgetsの設定
IntSliderでazimとelevを設定する。azimは横方向の視点で、elevは縦方向の視点となる。
視点の変更はax.view_init()で行う。
IntSliderを変化させたときの視点の変化


参考
Using Interact — Jupyter Widgets 8.1.5 documentation
https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html
コメント