Revision: 6077
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6077&view=rev
Author: jrevans
Date: 2008-09-09 23:15:59 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
Fixed some issues with unitized data. Some Patches were attempting to
calculate some results without knowing how to convert (not attached to any
Axes). A couple of Axes routines were assuming data was not unitized or not
converting the data at the appropriate place.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-09-09 12:58:33 UTC (rev
6076)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-09-09 23:15:59 UTC (rev
6077)
@@ -2679,10 +2679,12 @@
See :meth:`axhspan` for example plot and source code
"""
- ymin, ymax = self.get_ylim()
- if ymax<ymin: ymin, ymax = ymax, ymin
- scaley = (y<ymin) or (y>ymax)
+ ymin, ymax = self.get_ybound()
+ # We need to strip away the units for comparison with non-unitized
bounds
+ yy = self.convert_yunits( y )
+ scaley = (yy<ymin) or (yy>ymax)
+
trans = mtransforms.blended_transform_factory(
self.transAxes, self.transData)
l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False,
scaley=scaley, **kwargs)
@@ -2731,10 +2733,12 @@
See :meth:`axhspan` for example plot and source code
"""
- xmin, xmax = self.get_xlim()
- if xmax<xmin: xmin, xmax = xmax, xmin
- scalex = (x<xmin) or (x>xmax)
+ xmin, xmax = self.get_xbound()
+ # We need to strip away the units for comparison with non-unitized
bounds
+ xx = self.convert_xunits( x )
+ scalex = (xx<xmin) or (xx>xmax)
+
trans = mtransforms.blended_transform_factory(
self.transData, self.transAxes)
l, = self.plot([x,x], [ymin,ymax] , transform=trans, scalex=scalex,
scaley=False, **kwargs)
@@ -2876,9 +2880,15 @@
raise DeprecationWarning(
'hlines now uses a collections.LineCollection and not a list
of Line2D to draw; see API_CHANGES')
+ # We do the conversion first since not all unitized data is uniform
+ y = self.convert_yunits( y )
+ xmin = self.convert_xunits( xmin )
+ xmax = self.convert_xunits( xmax )
+
if not iterable(y): y = [y]
if not iterable(xmin): xmin = [xmin]
if not iterable(xmax): xmax = [xmax]
+
y = np.asarray(y)
xmin = np.asarray(xmin)
xmax = np.asarray(xmax)
@@ -2905,8 +2915,6 @@
miny = y.min()
maxy = y.max()
- minx, maxx = self.convert_xunits((minx, maxx))
- miny, maxy = self.convert_yunits((miny, maxy))
corners = (minx, miny), (maxx, maxy)
self.update_datalim(corners)
@@ -2947,9 +2955,15 @@
self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs)
+ # We do the conversion first since not all unitized data is uniform
+ x = self.convert_xunits( x )
+ ymin = self.convert_yunits( ymin )
+ ymax = self.convert_yunits( ymax )
+
if not iterable(x): x = [x]
if not iterable(ymin): ymin = [ymin]
if not iterable(ymax): ymax = [ymax]
+
x = np.asarray(x)
ymin = np.asarray(ymin)
ymax = np.asarray(ymax)
@@ -2973,17 +2987,12 @@
self.add_collection(coll)
coll.update(kwargs)
- # We do the conversion first since not all unitized data is uniform
- xx = self.convert_xunits( x )
- yymin = self.convert_yunits( ymin )
- yymax = self.convert_yunits( ymax )
+ minx = min( x )
+ maxx = max( x )
- minx = min( xx )
- maxx = max( xx )
+ miny = min( min(ymin), min(ymax) )
+ maxy = max( max(ymin), max(ymax) )
- miny = min( min(yymin), min(yymax) )
- maxy = max( max(yymin), max(yymax) )
-
corners = (minx, miny), (maxx, maxy)
self.update_datalim(corners)
self.autoscale_view()
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2008-09-09 12:58:33 UTC (rev
6076)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2008-09-09 23:15:59 UTC (rev
6077)
@@ -380,8 +380,8 @@
self._y = xy[1]
self._width = width
self._height = height
+ # Note: This cannot be calculated until this is added to an Axes
self._rect_transform = transforms.IdentityTransform()
- self._update_patch_transform()
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
def get_path(self):
@@ -391,6 +391,11 @@
return Path.unit_rectangle()
def _update_patch_transform(self):
+ """NOTE: This cannot be called until after this has been added
+ to an Axes, otherwise unit conversion will fail. This
+ maxes it very important to call the accessor method and
+ not directly access the transformation member variable.
+ """
x = self.convert_xunits(self._x)
y = self.convert_yunits(self._y)
width = self.convert_xunits(self._width)
@@ -946,11 +951,16 @@
self.width, self.height = width, height
self.angle = angle
self._path = Path.unit_circle()
+ # Note: This cannot be calculated until this is added to an Axes
self._patch_transform = transforms.IdentityTransform()
- self._recompute_transform()
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
def _recompute_transform(self):
+ """NOTE: This cannot be called until after this has been added
+ to an Axes, otherwise unit conversion will fail. This
+ maxes it very important to call the accessor method and
+ not directly access the transformation member variable.
+ """
center = (self.convert_xunits(self.center[0]),
self.convert_yunits(self.center[1]))
width = self.convert_xunits(self.width)
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