Here is a minor patch for the mplot3d.view_init() function. It:
1. comments this method so that users know that they can use it to
programatically rotate or re-set the axes.
2. adds some new functionality so that if no parameters are passed in, the
default values (what was specified in the Axes3D constructor) are used instead.
This diff was created with SVN head revision 8199.
I tested the new feature with my own code to verify it works, but don't have
any example code or test scripts to submit.
Thanks,
-Ben
Index: lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- lib/mpl_toolkits/mplot3d/axes3d.py (revision 8199)
+++ lib/mpl_toolkits/mplot3d/axes3d.py (working copy)
@@ -59,8 +59,8 @@
self.fig = fig
self._cids = []
- azim = kwargs.pop('azim', -60)
- elev = kwargs.pop('elev', 30)
+ self.initial_azim = kwargs.pop('azim', -60)
+ self.initial_elev = kwargs.pop('elev', 30)
self.xy_viewLim = unit_bbox()
self.zz_viewLim = unit_bbox()
@@ -68,7 +68,7 @@
self.zz_dataLim = unit_bbox()
# inihibit autoscale_view until the axises are defined
# they can't be defined until Axes.__init__ has been called
- self.view_init(elev, azim)
+ self.view_init(self.initial_elev, self.initial_azim)
self._ready = 0
Axes.__init__(self, self.fig, rect,
frameon=True,
@@ -272,11 +272,30 @@
def panpy(self, numsteps):
print 'numsteps', numsteps
- def view_init(self, elev, azim):
+ def view_init(self, elev=None, azim=None):
+ """Set the elevation and azimuth of the axes.
+
+ This can be used to rotate the axes programatically.
+
+ 'elev' stores the elevation angle in the z plane.
+ 'azim' stores the azimuth angle in the x,y plane.
+
+ if elev or azim are None (default), then the initial value
+ is used which was specified in the :class:`Axes3D` constructor.
+ """
+
self.dist = 10
- self.elev = elev
- self.azim = azim
-
+
+ if elev is None:
+ self.elev = self.initial_elev
+ else:
+ self.elev = elev
+
+ if azim is None:
+ self.azim = self.initial_azim
+ else:
+ self.azim = azim
+
def get_proj(self):
"""Create the projection matrix from the current viewing
position.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel