From: <jd...@us...> - 2007-09-12 15:41:28
|
Revision: 3838 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3838&view=rev Author: jdh2358 Date: 2007-09-12 08:41:22 -0700 (Wed, 12 Sep 2007) Log Message: ----------- removed Interval from canonical tickers and formatters Modified Paths: -------------- branches/transforms/lib/matplotlib/affine.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/ticker.py Modified: branches/transforms/lib/matplotlib/affine.py =================================================================== --- branches/transforms/lib/matplotlib/affine.py 2007-09-12 14:46:03 UTC (rev 3837) +++ branches/transforms/lib/matplotlib/affine.py 2007-09-12 15:41:22 UTC (rev 3838) @@ -33,6 +33,9 @@ self._points = N.asarray(points, N.float_) self.track = False + # JDH: if you define a del method, the garbage collector won't + # destory cyclic references, so make sure you either manage these + # yourself or remove the __del__ after testing def __del__(self): if self.track: print "Bbox::__del__" @@ -52,6 +55,11 @@ return Bbox([[left, bottom], [right, top]]) from_lbrt = staticmethod(from_lbrt) + + # JDH: the update method will update the box limits from the + # existing limits and the new data; it appears here you are just + # using the new data. We use an "ignore" flag to specify whether + # you want to include the existing data or not in the update def update_from_data(self, x, y): self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]], N.float_) self.invalidate() Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-09-12 14:46:03 UTC (rev 3837) +++ branches/transforms/lib/matplotlib/axis.py 2007-09-12 15:41:22 UTC (rev 3838) @@ -855,9 +855,9 @@ ACCEPTS: A Formatter instance """ self.major.formatter = formatter - self.major.formatter.set_view_interval( self.get_view_interval() ) - self.major.formatter.set_data_interval( self.get_data_interval() ) + self.major.formatter.set_axis(self) + def set_minor_formatter(self, formatter): """ Set the formatter of the minor ticker @@ -865,8 +865,7 @@ ACCEPTS: A Formatter instance """ self.minor.formatter = formatter - self.minor.formatter.set_view_interval( self.get_view_interval() ) - self.minor.formatter.set_data_interval( self.get_data_interval() ) + self.minor.formatter.set_axis(self) def set_major_locator(self, locator): @@ -876,8 +875,7 @@ ACCEPTS: a Locator instance """ self.major.locator = locator - self.major.locator.set_view_interval( self.get_view_interval() ) - self.major.locator.set_data_interval( self.get_data_interval() ) + self.major.locator.set_axis(self) def set_minor_locator(self, locator): @@ -887,8 +885,7 @@ ACCEPTS: a Locator instance """ self.minor.locator = locator - self.minor.locator.set_view_interval( self.get_view_interval() ) - self.minor.locator.set_data_interval( self.get_data_interval() ) + self.minor.locator.set_axis(self) def set_pickradius(self, pickradius): """ Modified: branches/transforms/lib/matplotlib/ticker.py =================================================================== --- branches/transforms/lib/matplotlib/ticker.py 2007-09-12 14:46:03 UTC (rev 3837) +++ branches/transforms/lib/matplotlib/ticker.py 2007-09-12 15:41:22 UTC (rev 3838) @@ -99,13 +99,7 @@ minor ticks. See the matplotlib.dates module for more information and examples of using date locators and formatters. -DEVELOPERS NOTE -If you are implementing your own class or modifying one of these, it -is critical that you use viewlim and dataInterval READ ONLY MODE so -multiple axes can share the same locator w/o side effects! - - """ @@ -121,37 +115,11 @@ class TickHelper: + axis = None + def set_axis(self, axis): + self.axis = axis - viewInterval = None - dataInterval = None - def verify_intervals(self): - if self.dataInterval is None: - raise RuntimeError("You must set the data interval to use this function") - - if self.viewInterval is None: - raise RuntimeError("You must set the view interval to use this function") - - - def set_view_interval(self, interval): - self.viewInterval = interval - - def set_data_interval(self, interval): - self.dataInterval = interval - - def set_bounds(self, vmin, vmax): - ''' - Set dataInterval and viewInterval from numeric vmin, vmax. - - This is for stand-alone use of Formatters and/or - Locators that require these intervals; that is, for - cases where the Intervals do not need to be updated - automatically. - ''' - # MGDTODO: Interval no longer exists - self.dataInterval = maffine.Interval([vmin, vmax]) - self.viewInterval = maffine.Interval([vmin, vmax]) - class Formatter(TickHelper): """ Convert the tick location to a string @@ -341,9 +309,8 @@ 'set the locations of the ticks' self.locs = locs if len(self.locs) > 0: - self.verify_intervals() - vmin, vmax = self.viewInterval - d = abs(vmax - vmin) + vmin, vmax = self.axis.get_view_interval() + d = abs(vmax-vmin) if self._useOffset: self._set_offset(d) self._set_orderOfMagnitude(d) self._set_format() @@ -865,14 +832,12 @@ def __call__(self): - self.verify_intervals() - vmin, vmax = self.viewInterval + vmin, vmax = self.axis.get_view_interval() vmin, vmax = maffine.nonsingular(vmin, vmax, expander = 0.05) return self.bin_boundaries(vmin, vmax) def autoscale(self): - self.verify_intervals() - dmin, dmax = self.dataInterval + dmin, dmax = self.axis.get_data_interval() dmin, dmax = maffine.nonsingular(dmin, dmax, expander = 0.05) return npy.take(self.bin_boundaries(dmin, dmax), [0,-1]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |