Hello all,
I have always been a bit troubled with how Axes3D object is a bit of a 2nd-class citizen in matplotlib. In particular, it is very common to create a new axes using .add_subplot() or .gca(), but you can’t do that with Axes3D. You also can’t create subplots of 3d figures, you have to create multiple figures with single 3d plots in them.
My examination off the code have not revealed anything that prevents this from happening. Currently, the gca() and add_subplot() functions accept a kwarg of ‘projection’ which allows one to specify the name of a registered axes object. Currently axes.Axes, polar and a few others are registered, with axes.Axes being default.
I have found that 3 lines of code in the axes3d module to have it add the Axes3D class to the registry. Using a name of ‘3d’, one can specify the projection to gain a Axes3d object. Note, you will still have to import the Axes3D object as usual. Attached is a patch for axes3d.py and a file that could be added to mpl_examples/. Give it a shot and let me know how it works for you!
Enjoy!
Ben Root
P.S. - Can you just imagine subplots of animated 3d plots? wink… wink…
Axes3DSubplot.patch (754 Bytes)
subplot3d_demo.py (872 Bytes)