Revision: 6017
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6017&view=rev
Author: efiring
Date: 2008-08-11 07:09:16 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
Eliminate duplicate Path instantiation
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-08-10 23:49:21 UTC (rev
6016)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-08-11 07:09:16 UTC (rev
6017)
@@ -1282,8 +1282,9 @@
line._remove_method = lambda h: self.lines.remove(h)
def _update_line_limits(self, line):
- xydata = line.get_xydata()
- self.update_datalim( xydata )
+ self.dataLim.update_from_path(line.get_path(),
+ self.ignore_existing_data_limits)
+ self.ignore_existing_data_limits = False
def add_patch(self, p):
"""
@@ -1307,12 +1308,11 @@
# the auto-scaling
if isinstance(p, mpatches.Rectangle) and (p.get_width()==0. or
p.get_height()==0.):
return
-
vertices = p.get_patch_transform().transform(p.get_path().vertices)
if p.get_data_transform() != self.transData:
transform = p.get_data_transform() + self.transData.inverted()
xys = transform.transform(vertices)
-
+ # Something is wrong--xys is never used.
self.update_datalim(vertices)
def add_table(self, tab):
@@ -1327,6 +1327,8 @@
def relim(self):
'recompute the data limits based on current artists'
+ # Collections are deliberately not supported (yet); see
+ # the TODO note in artists.py.
self.dataLim.ignore(True)
self.ignore_existing_data_limits = True
for line in self.lines:
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py 2008-08-10 23:49:21 UTC
(rev 6016)
+++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-08-11 07:09:16 UTC
(rev 6017)
@@ -786,12 +786,12 @@
xy = np.hstack((x.reshape((len(x), 1)), y.reshape((len(y), 1))))
return self.update_from_data_xy(xy, ignore)
- def update_from_data_xy(self, xy, ignore=None):
+ def update_from_path(self, path, ignore=None):
"""
Update the bounds of the :class:`Bbox` based on the passed in
data.
- xy: a numpy array of 2D points
+ path: a Path instance
ignore:
- when True, ignore the existing bounds of the Bbox.
@@ -801,20 +801,33 @@
if ignore is None:
ignore = self._ignore
- if len(xy) == 0:
- return
- xym = ma.masked_invalid(xy) # maybe add copy=False
- if (xym.count(axis=1)!=2).all():
- return
-
points, minpos, changed = update_path_extents(
- Path(xym), None, self._points, self._minpos, ignore)
+ path, None, self._points, self._minpos, ignore)
if changed:
self._points = points
self._minpos = minpos
self.invalidate()
+
+ def update_from_data_xy(self, xy, ignore=None):
+ """
+ Update the bounds of the :class:`Bbox` based on the passed in
+ data.
+
+ xy: a numpy array of 2D points
+
+ ignore:
+ - when True, ignore the existing bounds of the Bbox.
+ - when False, include the existing bounds of the Bbox.
+ - when None, use the last value passed to :meth:`ignore`.
+ """
+ if len(xy) == 0:
+ return
+
+ path = Path(xy)
+ self.update_from_path(path, ignore=ignore)
+
def _set_x0(self, val):
self._points[0, 0] = val
self.invalidate()
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 Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins