Notebook

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

HTML ファイル生成日時: 2024/10/16 21:52:27.872 (台灣標準時)

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. Computer___Python/20220518_0.html
  2. Computer___Network/20230726_00.html
  3. Computer___Network/20230516_00.html
  4. Misc___Taiwan/20240207_00.html
  5. Computer___FreeBSD/20220621_0.html
  6. Computer___Python/20220715_0.html
  7. Food___Taiwan/20220429_0.html
  8. Computer___Network/20230508_00.html
  9. Computer___NetBSD/20220817_3.html
  10. Computer___Python/20220410_0.html
  11. Computer___Network/20240416_00.html
  12. Computer___Debian/20210223_1.html
  13. Computer___Python/20210124_0.html
  14. Computer___Network/20240130_00.html
  15. Computer___NetBSD/20220818_1.html
  16. Computer___NetBSD/20220428_0.html
  17. Computer___NetBSD/20230119_00.html
  18. Computer___Python/20221013_0.html
  19. Science___Math/20220420_0.html
  20. Computer___NetBSD/20230515_00.html
  21. Computer___TeX/20230503_00.html
  22. Computer___NetBSD/20240101_02.html
  23. Science___Astronomy/20220503_0.html
  24. Computer___NetBSD/20220808_0.html
  25. Computer___Python/20240101_00.html
  26. Computer___NetBSD/20210127_0.html
  27. Computer___NetBSD/20210204_0.html
  28. Travel___Taiwan/20220809_2.html
  29. Computer___Python/20220816_1.html
  30. Computer___Network/20220413_1.html


HTML file generated by Kinoshita Daisuke.