Revision: 6936
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6936&view=rev
Author:   efiring
Date:     2009-02-26 00:12:33 +0000 (Thu, 26 Feb 2009)

Log Message:
-----------
Improve tick location subsetting in FixedLocator.
Now it includes zero, if present.

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/ticker.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2009-02-25 15:45:45 UTC (rev 6935)
+++ trunk/matplotlib/CHANGELOG  2009-02-26 00:12:33 UTC (rev 6936)
@@ -1,4 +1,6 @@
-2009-02-25 Deprecate numerix, and strip out all but the numpy
+2009-02-25 Improve tick location subset choice in FixedLocator. - EF
+
+2009-02-24 Deprecate numerix, and strip out all but the numpy
            part of the code. - EF
 
 2009-02-21 Improve scatter argument handling; add an early error

Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py   2009-02-25 15:45:45 UTC (rev 
6935)
+++ trunk/matplotlib/lib/matplotlib/ticker.py   2009-02-26 00:12:33 UTC (rev 
6936)
@@ -708,10 +708,14 @@
     Tick locations are fixed.  If nbins is not None,
     the array of possible positions will be subsampled to
     keep the number of ticks <= nbins +1.
+    The subsampling will be done so as to include the smallest
+    absolute value; for example, if zero is included in the
+    array of possibilities, then it is guaranteed to be one of
+    the chosen ticks.
     """
 
     def __init__(self, locs, nbins=None):
-        self.locs = locs
+        self.locs = np.asarray(locs)
         self.nbins = nbins
         if self.nbins is not None:
             self.nbins = max(self.nbins, 2)
@@ -721,7 +725,12 @@
         if self.nbins is None:
             return self.locs
         step = max(int(0.99 + len(self.locs) / float(self.nbins)), 1)
-        return self.locs[::step]
+        ticks = self.locs[::step]
+        for i in range(1,step):
+            ticks1 = self.locs[i::step]
+            if np.absolute(ticks1).min() < np.absolute(ticks).min():
+                ticks = ticks1
+        return ticks
 
 
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to