Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2025/11/23 20:31:30.065 (台灣標準時)

Matplotlib の 3D plot においての注意点

Matplotlib の 3D plot を使う際、 ax.plot_surface () を使うと、 ax.plot_surface () を使って描画したもの同士の前後の関係は自動で判別さ れ、奥にあるべきものは奥に配置されて、手前にあるべきものは手前に配置さ れるでござる。なれど、 ax.plot_surface () と ax.plot () や ax.scatter () を混在させると、手前にあるべきものが奥に配置されたり、奥にあるべき ものが手前に配置されてしまったりするようでござる。

太陽と八個の惑星と十万個の小惑星をプロットしようと思ったときに、十万個 の小惑星を一個ずつプロットすると時間がかかりすぎるので、 ax.plot () や ax.scatter () に十万個の小惑星の座標を一度に渡して描画させることにした でござる。ところが、こうすると、太陽と惑星が常に小惑星帯の手前にあるよ うに描画されてしまったり、常に小惑星帯の後側にあるように描画されてしまっ たでござる。

これを解決するためには、 axes object を作るときに、

computed_zorder=False
というオプションを指定すればよいよう でござる。こうすると、描画の順番を自分で指定できるようになるようでござ る。ただし、この場合、すべてのものの前後の関係を自分で確認して、その上 で描画の順番を決めなくてはならなくなるので、手間がかかるでござる。


ax = fig.add_axes ( (0, 0, 1, 1), projection='3d', computed_zorder=False)

computed_zorder=False
オプション付きで
fig.add_axes ()
を使って axes object を作り、そのうえで ax.plot_surface (), ax.plot (), ax.scatter () などを使うときに、 zorder で描画の順序を決めれば、期待通りの図になるようでござる。

参考文献



Frequently accessed files

  1. Misc___Taiwan/20240207_00.html
  2. Computer___TeX/20231107_00.html
  3. Misc___Taiwan/20240819_00.html
  4. Misc___Taiwan/20240903_01.html
  5. Computer___TeX/20240411_00.html
  6. Computer___TeX/20230726_01.html
  7. Computer___Python/20250330_00.html
  8. Computer___TeX/20240414_01.html
  9. Computer___NetBSD/20230119_00.html
  10. Computer___Network/20240130_00.html
  11. Computer___NetBSD/20250301_01.html
  12. Computer___Python/20220715_0.html
  13. Computer___NetBSD/20250307_00.html
  14. Misc___Japan/20240718_00.html
  15. Computer___FreeBSD/20220621_0.html
  16. Misc___Japan/20240610_00.html
  17. Computer___NetBSD/20230121_00.html
  18. Computer___NetBSD/20240810_00.html
  19. Computer___NetBSD/20241223_00.html
  20. Computer___NetBSD/20240805_03.html
  21. Computer___Hardware/20240820_00.html
  22. Computer___Network/20251123_00.html
  23. Computer___NetBSD/20220406_0.html
  24. Computer___TeX/20240410_00.html
  25. Computer___NetBSD/20220506_0.html
  26. Computer___Python/20220518_0.html
  27. Computer___Network/20240416_00.html
  28. Book___Chinese/20240424_00.html
  29. Food___Taiwan/20230622_13.html
  30. Computer___TeX/20240414_00.html


HTML file generated by Kinoshita Daisuke.