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

Skip to content

Commit 80cc9aa

Browse files
committed
Major speed improvement for non-rectilinear projections.
svn path=/branches/transforms/; revision=4782
1 parent 84f3393 commit 80cc9aa

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

lib/matplotlib/axis.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ def update_position(self, loc):
304304
'Set the location of tick in data coords with scalar loc'
305305
x = loc
306306

307+
nonlinear = (hasattr(self.axes, 'yaxis') and
308+
self.axes.yaxis.get_scale() != 'linear' or
309+
hasattr(self.axes, 'xaxis') and
310+
self.axes.xaxis.get_scale() != 'linear')
311+
307312
if self.tick1On:
308313
self.tick1line.set_xdata((x,))
309314
if self.tick2On:
@@ -314,6 +319,12 @@ def update_position(self, loc):
314319
self.label1.set_x(x)
315320
if self.label2On:
316321
self.label2.set_x(x)
322+
323+
if nonlinear:
324+
self.tick1line._invalid = True
325+
self.tick2line._invalid = True
326+
self.gridline._invalid = True
327+
317328
self._loc = loc
318329

319330
def get_view_interval(self):
@@ -425,6 +436,12 @@ def _get_gridline(self):
425436
def update_position(self, loc):
426437
'Set the location of tick in data coords with scalar loc'
427438
y = loc
439+
440+
nonlinear = (hasattr(self.axes, 'yaxis') and
441+
self.axes.yaxis.get_scale() != 'linear' or
442+
hasattr(self.axes, 'xaxis') and
443+
self.axes.xaxis.get_scale() != 'linear')
444+
428445
if self.tick1On:
429446
self.tick1line.set_ydata((y,))
430447
if self.tick2On:
@@ -435,6 +452,11 @@ def update_position(self, loc):
435452
self.label1.set_y( y )
436453
if self.label2On:
437454
self.label2.set_y( y )
455+
if nonlinear:
456+
self.tick1line._invalid = True
457+
self.tick2line._invalid = True
458+
self.gridline._invalid = True
459+
438460
self._loc = loc
439461

440462

lib/matplotlib/lines.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ def set_data(self, *args):
396396
self._xorig = x
397397
self._yorig = y
398398
self._invalid = True
399-
else:
400-
if hasattr(self, "_transformed_path"):
401-
self._transformed_path._invalid = self._transformed_path.INVALID_NON_AFFINE
402399

403400
def recache(self):
404401
#if self.axes is None: print 'recache no axes'

lib/matplotlib/transforms.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ def invalidate(self):
9393
"""
9494
# If we are an affine transform being changed, we can set the
9595
# flag to INVALID_AFFINE_ONLY
96-
value = ((self.is_affine or self.is_bbox)
97-
and self.INVALID_AFFINE
98-
or self.INVALID)
96+
value = (self.is_affine) and self.INVALID_AFFINE or self.INVALID
9997

10098
# Shortcut: If self is already invalid, that means its parents
10199
# are as well, so we don't need to do anything.
102-
if self._invalid == value or not len(self._parents):
100+
if self._invalid == value:
101+
return
102+
103+
if not len(self._parents):
104+
self._invalid = value
103105
return
104106

105107
# Invalidate all ancestors of self using pseudo-recursion.
@@ -108,7 +110,7 @@ def invalidate(self):
108110
while len(stack):
109111
root = stack.pop()
110112
# Stop at subtrees that have already been invalidated
111-
if root._invalid == 0 or root.pass_through:
113+
if root._invalid != value or root.pass_through:
112114
root._invalid = value
113115
stack.extend(root._parents.keys())
114116

@@ -198,6 +200,7 @@ class BboxBase(TransformNode):
198200
read-only access to its data.
199201
"""
200202
is_bbox = True
203+
is_affine = True
201204

202205
#* Redundant: Removed for performance
203206
#
@@ -208,6 +211,7 @@ class BboxBase(TransformNode):
208211
def _check(points):
209212
if ma.isMaskedArray(points):
210213
warnings.warn("Bbox bounds are a masked array.")
214+
points = npy.asarray(points)
211215
if (points[1,0] - points[0,0] == 0 or
212216
points[1,1] - points[0,1] == 0):
213217
warnings.warn("Singular Bbox.")
@@ -1011,6 +1015,8 @@ class TransformWrapper(Transform):
10111015
transform may only be replaced with another child transform of the
10121016
same dimensions.
10131017
"""
1018+
pass_through = True
1019+
10141020
def __init__(self, child):
10151021
"""
10161022
child: A Transform instance. This child may later be replaced
@@ -1546,7 +1552,6 @@ class BlendedAffine2D(Affine2DBase):
15461552
This version is an optimization for the case where both child
15471553
transforms are of type Affine2DBase.
15481554
"""
1549-
15501555
is_separable = True
15511556

15521557
def __init__(self, x_transform, y_transform):
@@ -1917,8 +1922,8 @@ def get_transformed_path_and_affine(self):
19171922
the transform already applied, along with the affine part of
19181923
the path necessary to complete the transformation.
19191924
"""
1920-
if (self._invalid & self.INVALID_NON_AFFINE or
1921-
self._transformed_path is None):
1925+
if ((self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
1926+
or self._transformed_path is None):
19221927
self._transformed_path = \
19231928
self._transform.transform_path_non_affine(self._path)
19241929
self._invalid = 0
@@ -1928,7 +1933,7 @@ def get_fully_transformed_path(self):
19281933
"""
19291934
Return a fully-transformed copy of the child path.
19301935
"""
1931-
if (self._invalid & self.INVALID_NON_AFFINE
1936+
if ((self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
19321937
or self._transformed_path is None):
19331938
self._transformed_path = \
19341939
self._transform.transform_path_non_affine(self._path)

0 commit comments

Comments
 (0)