Revision: 8044 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8044&view=rev Author: astraw Date: 2009-12-21 00:46:59 +0000 (Mon, 21 Dec 2009)
Log Message: ----------- spines: default transform is in data units, add set_bounds() call Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/spines.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-12-21 00:46:30 UTC (rev 8043) +++ trunk/matplotlib/CHANGELOG 2009-12-21 00:46:59 UTC (rev 8044) @@ -1,3 +1,6 @@ +2009-12-20 spines: put spines in data coordinates, add set_bounds() + call. -ADS + 2009-12-18 Don't limit notch size in boxplot to q1-q3 range, as this is effectively making the data look better than it is. - ADS Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-12-21 00:46:30 UTC (rev 8043) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-12-21 00:46:59 UTC (rev 8044) @@ -2065,6 +2065,9 @@ other.figure.canvas is not None): other.figure.canvas.draw_idle() + for loc in ('bottom','top'): + self.spines[loc].set_bounds(xmin,xmax) + return xmin, xmax def get_xscale(self): @@ -2238,6 +2241,10 @@ if (other.figure != self.figure and other.figure.canvas is not None): other.figure.canvas.draw_idle() + + for loc in ('left','right'): + self.spines[loc].set_bounds(ymin,ymax) + return ymin, ymax def get_yscale(self): Modified: trunk/matplotlib/lib/matplotlib/spines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/spines.py 2009-12-21 00:46:30 UTC (rev 8043) +++ trunk/matplotlib/lib/matplotlib/spines.py 2009-12-21 00:46:59 UTC (rev 8044) @@ -55,7 +55,7 @@ self.axis = None self.set_zorder(2.5) - self.set_transform(self.axes.transAxes) # default transform + self.set_transform(self.axes.transData) # default transform # Defer initial position determination. (Not much support for # non-rectangular axes is currently implemented, and this lets @@ -82,6 +82,7 @@ self._width = radius*2 self._height = radius*2 self._angle = 0 + self.set_transform(self.axes.transAxes) # circle drawn on axes transform def set_patch_line(self): """set the spine to be linear""" @@ -229,9 +230,9 @@ t = self.get_spine_transform() if self.spine_type in ['left','right']: t2 = mtransforms.blended_transform_factory(t, - self.axes.transAxes) + self.axes.transData) elif self.spine_type in ['bottom','top']: - t2 = mtransforms.blended_transform_factory(self.axes.transAxes, + t2 = mtransforms.blended_transform_factory(self.axes.transData, t) self.set_transform(t2) @@ -278,6 +279,19 @@ else: raise ValueError("unknown spine_transform type: %s"%what) + def set_bounds( self, low, high ): + v1 = self._path.vertices[:] # copy + assert v1.shape == (2,2), 'unexpected vertices shape' + if self.spine_type in ['left','right']: + v1[0,1] = low + v1[1,1] = high + elif self.spine_type in ['bottom','top']: + v1[0,0] = low + v1[1,0] = high + else: + raise ValueError('unable to set bounds for spine "%s"'%spine_type) + self._path.vertices = v1 # replace + @classmethod def linear_spine(cls, axes, spine_type, **kwargs): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins