はじめに
matplotlibのmplot3dで3Dグラフ上に楕円体を表示する方法について説明する。
コード

解説
モジュールのインポート
バージョン
3Dグラフの設定
データの生成
楕円体は球と同様に、極座標的な媒介変数でデータを生成する。
θを0〜2π,φを0〜πとすると、楕円体は以下の式で表すことができる。
ここでa,b,cは各x,y,z軸方向の径の半分の長さとなる。
a=b=cの場合は球になる。球については下記で解説した。

[matplotlib 3D] 18. 3D surfaceプロットで球を表示
matplotlibのmplot3dをつかって、3Dグラフ上にsurface plotで球を表示する方法について解説する。
軸範囲、軸ラベルの設定
3D wireframe グラフでの表示
rcount, ccountはwireを描写するwire数となるので、rcount=25で25本のwireが描写される。colorはwireの色となる。
回転アニメーション
作製した図を回転させると以下のようになる。
回転アニメーションは以下の記事を参考にして作成した。

[matplotlib 3D] 14. 3Dグラフの回転アニメーション
matplotlib mplot3d のグラフの回転アニメーション
参考

楕円体 - Wikipedia
List of named colors — Matplotlib 3.10.0 documentation
コメント