Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving 3D-plot in PDF 3D with Python

I've generated a 3D plot with python and pyplot. I am able to export this plot to PDF. Which is quite boring and sometimes.. Flat 3D plots can be hard to read/understand.

However, PDF supports interactive 3D models, such as CAD models. This made me wonder if it is possible to export a 3D plot generated by matplotlib or something similar, to 3D PDF? This would be amazing to store beautiful 3D plots! If so, how can I do this?

like image 847
SjonTeflon Avatar asked Feb 19 '16 15:02

SjonTeflon


1 Answers

Not so much an answer as a summary of my research so far:

  • a previous question asked pretty much the same but came to no conclusion

  • .pdf supports two internal 3d formats - u3d (since version 7), and prc (since version 8). prc is a more complicated but more compact format.

  • (c. 2006): Acrobat 3d supports many more formats - over 40 - but does so by converting them to u3d for import (reference)

  • (Dec 2013): matplotlib's drawing core is 2d only; mplot3d is just a workaround, everything gets projected to 2d before being rendered. (reference) Link to GlumPy?

At the moment, I see two likely approaches:

  • write a new 3d output engine for matplotlib to u3d

  • write a 3d renderer for matplotlib to OpenGL (Acrobat 3d can capture the contents of an active OpenGL frame)

like image 148
Hugh Bothwell Avatar answered Oct 19 '22 01:10

Hugh Bothwell