Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36ab0f9

Browse files
committed
removed Interval from canonical tickers and formatters
svn path=/branches/transforms/; revision=3838
1 parent 32f6677 commit 36ab0f9

3 files changed

Lines changed: 20 additions & 50 deletions

File tree

lib/matplotlib/affine.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, points):
3333
self._points = N.asarray(points, N.float_)
3434
self.track = False
3535

36+
# JDH: if you define a del method, the garbage collector won't
37+
# destory cyclic references, so make sure you either manage these
38+
# yourself or remove the __del__ after testing
3639
def __del__(self):
3740
if self.track:
3841
print "Bbox::__del__"
@@ -52,6 +55,11 @@ def from_lbrt(left, bottom, right, top):
5255
return Bbox([[left, bottom], [right, top]])
5356
from_lbrt = staticmethod(from_lbrt)
5457

58+
59+
# JDH: the update method will update the box limits from the
60+
# existing limits and the new data; it appears here you are just
61+
# using the new data. We use an "ignore" flag to specify whether
62+
# you want to include the existing data or not in the update
5563
def update_from_data(self, x, y):
5664
self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]], N.float_)
5765
self.invalidate()

lib/matplotlib/axis.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ def set_major_formatter(self, formatter):
855855
ACCEPTS: A Formatter instance
856856
"""
857857
self.major.formatter = formatter
858-
self.major.formatter.set_view_interval( self.get_view_interval() )
859-
self.major.formatter.set_data_interval( self.get_data_interval() )
858+
self.major.formatter.set_axis(self)
859+
860860

861861
def set_minor_formatter(self, formatter):
862862
"""
@@ -865,8 +865,7 @@ def set_minor_formatter(self, formatter):
865865
ACCEPTS: A Formatter instance
866866
"""
867867
self.minor.formatter = formatter
868-
self.minor.formatter.set_view_interval( self.get_view_interval() )
869-
self.minor.formatter.set_data_interval( self.get_data_interval() )
868+
self.minor.formatter.set_axis(self)
870869

871870

872871
def set_major_locator(self, locator):
@@ -876,8 +875,7 @@ def set_major_locator(self, locator):
876875
ACCEPTS: a Locator instance
877876
"""
878877
self.major.locator = locator
879-
self.major.locator.set_view_interval( self.get_view_interval() )
880-
self.major.locator.set_data_interval( self.get_data_interval() )
878+
self.major.locator.set_axis(self)
881879

882880

883881
def set_minor_locator(self, locator):
@@ -887,8 +885,7 @@ def set_minor_locator(self, locator):
887885
ACCEPTS: a Locator instance
888886
"""
889887
self.minor.locator = locator
890-
self.minor.locator.set_view_interval( self.get_view_interval() )
891-
self.minor.locator.set_data_interval( self.get_data_interval() )
888+
self.minor.locator.set_axis(self)
892889

893890
def set_pickradius(self, pickradius):
894891
"""

lib/matplotlib/ticker.py

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@
9999
minor ticks. See the matplotlib.dates module for more information and
100100
examples of using date locators and formatters.
101101
102-
DEVELOPERS NOTE
103-
104-
If you are implementing your own class or modifying one of these, it
105-
is critical that you use viewlim and dataInterval READ ONLY MODE so
106-
multiple axes can share the same locator w/o side effects!
107-
108102
109103
"""
110104

@@ -121,36 +115,10 @@
121115

122116

123117
class TickHelper:
118+
axis = None
119+
def set_axis(self, axis):
120+
self.axis = axis
124121

125-
viewInterval = None
126-
dataInterval = None
127-
128-
def verify_intervals(self):
129-
if self.dataInterval is None:
130-
raise RuntimeError("You must set the data interval to use this function")
131-
132-
if self.viewInterval is None:
133-
raise RuntimeError("You must set the view interval to use this function")
134-
135-
136-
def set_view_interval(self, interval):
137-
self.viewInterval = interval
138-
139-
def set_data_interval(self, interval):
140-
self.dataInterval = interval
141-
142-
def set_bounds(self, vmin, vmax):
143-
'''
144-
Set dataInterval and viewInterval from numeric vmin, vmax.
145-
146-
This is for stand-alone use of Formatters and/or
147-
Locators that require these intervals; that is, for
148-
cases where the Intervals do not need to be updated
149-
automatically.
150-
'''
151-
# MGDTODO: Interval no longer exists
152-
self.dataInterval = maffine.Interval([vmin, vmax])
153-
self.viewInterval = maffine.Interval([vmin, vmax])
154122

155123
class Formatter(TickHelper):
156124
"""
@@ -341,9 +309,8 @@ def set_locs(self, locs):
341309
'set the locations of the ticks'
342310
self.locs = locs
343311
if len(self.locs) > 0:
344-
self.verify_intervals()
345-
vmin, vmax = self.viewInterval
346-
d = abs(vmax - vmin)
312+
vmin, vmax = self.axis.get_view_interval()
313+
d = abs(vmax-vmin)
347314
if self._useOffset: self._set_offset(d)
348315
self._set_orderOfMagnitude(d)
349316
self._set_format()
@@ -865,14 +832,12 @@ def bin_boundaries(self, vmin, vmax):
865832

866833

867834
def __call__(self):
868-
self.verify_intervals()
869-
vmin, vmax = self.viewInterval
835+
vmin, vmax = self.axis.get_view_interval()
870836
vmin, vmax = maffine.nonsingular(vmin, vmax, expander = 0.05)
871837
return self.bin_boundaries(vmin, vmax)
872838

873839
def autoscale(self):
874-
self.verify_intervals()
875-
dmin, dmax = self.dataInterval
840+
dmin, dmax = self.axis.get_data_interval()
876841
dmin, dmax = maffine.nonsingular(dmin, dmax, expander = 0.05)
877842
return npy.take(self.bin_boundaries(dmin, dmax), [0,-1])
878843

0 commit comments

Comments
 (0)