Revision: 3960 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3960&view=rev Author: mdboom Date: 2007-10-18 07:51:16 -0700 (Thu, 18 Oct 2007)
Log Message: ----------- More examples working. Minor speedups. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/pyplot.py branches/transforms/lib/matplotlib/quiver.py branches/transforms/lib/matplotlib/transforms.py Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/PASSED_DEMOS 2007-10-18 14:51:16 UTC (rev 3960) @@ -164,8 +164,8 @@ pstest.py pylab_with_gtk.py pythonic_matplotlib.py O -quadmesh_demo.py [MASKED VALUES NOT QUITE RIGHT] -quiver_demo.py [SEGFAULTS] +quadmesh_demo.py O [MASKED VALUES ARE SHOWN DUE TO A BUG IN TRUNK] +quiver_demo.py O rc_traits.py [N/A] scatter_custom_symbol.py O scatter_demo2.py O Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-18 14:51:16 UTC (rev 3960) @@ -356,7 +356,6 @@ If the scalar mappable array is not none, update colors from scalar data """ - #print 'update_scalarmappable: self._A', self._A if self._A is None: return if len(self._A.shape)>1: raise ValueError('Collections can only map rank 1 arrays') @@ -364,7 +363,6 @@ self._facecolors = self.to_rgba(self._A, self._alpha) else: self._edgecolors = self.to_rgba(self._A, self._alpha) - #print self._facecolors # these are not available for the object inspector until after the @@ -445,7 +443,7 @@ return self._paths def draw(self, renderer): - self.update_scalarmappable() ####################### + self.update_scalarmappable() self._linewidths = (1,) if self._showedges: Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/lib/matplotlib/lines.py 2007-10-18 14:51:16 UTC (rev 3960) @@ -281,6 +281,8 @@ if is_numlike(self._picker): self.pickradius = self._picker + self._xorig = npy.asarray([]) + self._yorig = npy.asarray([]) self.set_data(xdata, ydata) self._logcache = None @@ -377,9 +379,13 @@ else: x, y = args - self._xorig = x - self._yorig = y - self.recache() + x = npy.asarray(x) + y = npy.asarray(y) + if ((x.shape != self._xorig.shape or npy.any(x != self._xorig)) or + (y.shape != self._yorig.shape or npy.any(y != self._yorig))): + self._xorig = x + self._yorig = y + self.recache() def recache(self): #if self.axes is None: print 'recache no axes' @@ -625,8 +631,10 @@ ACCEPTS: npy.array """ - self._xorig = x - self.recache() + x = npy.asarray(x) + if x.shape != self._xorig.shape or npy.any(x != self._xorig): + self._xorig = x + self.recache() def set_ydata(self, y): """ @@ -634,10 +642,11 @@ ACCEPTS: npy.array """ + y = npy.asarray(y) + if y.shape != self._yorig.shape or npy.any(y != self._yorig): + self._yorig = y + self.recache() - self._yorig = y - self.recache() - def set_dashes(self, seq): """ Set the dash sequence, sequence of dashes with on off ink in Modified: branches/transforms/lib/matplotlib/pyplot.py =================================================================== --- branches/transforms/lib/matplotlib/pyplot.py 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/lib/matplotlib/pyplot.py 2007-10-18 14:51:16 UTC (rev 3960) @@ -312,7 +312,7 @@ A matplotlib.legend.Legend instance is returned """ - l= gcf().legend(handles, labels, loc, **kwargs) + l = gcf().legend(handles, labels, loc, **kwargs) draw_if_interactive() return l Modified: branches/transforms/lib/matplotlib/quiver.py =================================================================== --- branches/transforms/lib/matplotlib/quiver.py 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/lib/matplotlib/quiver.py 2007-10-18 14:51:16 UTC (rev 3960) @@ -206,24 +206,24 @@ def _text_x(self, x): if self.labelpos == 'E': - return x + self.labelsep.get() + return x + self.labelsep elif self.labelpos == 'W': - return x - self.labelsep.get() + return x - self.labelsep else: return x def _text_y(self, y): if self.labelpos == 'N': - return y + self.labelsep.get() + return y + self.labelsep elif self.labelpos == 'S': - return y - self.labelsep.get() + return y - self.labelsep else: return y def draw(self, renderer): self._init() self.vector.draw(renderer) - x, y = self.get_transform().xy_tup((self.X, self.Y)) + x, y = self.get_transform().transform_point((self.X, self.Y)) self.text.set_x(self._text_x(x)) self.text.set_y(self._text_y(y)) self.text.draw(renderer) @@ -323,7 +323,7 @@ if not self._initialized: trans = self._set_transform() ax = self.ax - sx, sy = trans.transform_point((ax.bbox.width, ax.bbox.height)) + sx, sy = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height)) self.span = sx sn = max(8, min(25, math.sqrt(self.N))) if self.width is None: @@ -333,12 +333,7 @@ self._init() if self._new_UV: verts = self._make_verts(self.U, self.V) - # Using nan internally here is the easiest - # way to support masked inputs; it doesn't - # require adding mask support to PolyCollection, - # and it keeps all array dimensions (X, Y, U, V, C) - # intact. - self.set_verts(verts.filled(npy.nan)) + self.set_verts(verts) self._new_UV = False collections.PolyCollection.draw(self, renderer) @@ -353,11 +348,11 @@ ax = self.ax if self.units in ('x', 'y'): if self.units == 'x': - dx0 = ax.viewLim.ur().x() - ax.viewLim.ll().x() - dx1 = ax.bbox.ur().x() - ax.bbox.ll().x() + dx0 = ax.viewLim.width + dx1 = ax.bbox.width else: - dx0 = ax.viewLim.ur().y() - ax.viewLim.ll().y() - dx1 = ax.bbox.ur().y() - ax.bbox.ll().y() + dx0 = ax.viewLim.height + dx1 = ax.bbox.height dx = dx1/dx0 else: if self.units == 'width': @@ -365,13 +360,12 @@ elif self.units == 'height': dx = ax.bbox.height elif self.units == 'dots': - dx = transforms.Value(1) + dx = 1.0 elif self.units == 'inches': dx = ax.figure.dpi else: raise ValueError('unrecognized units') - bb = transforms.Bbox.from_lbrt(0, 0, dx, dx) - trans = transforms.BboxTransform(transforms.Bbox.unit(), bb) + trans = transforms.Affine2D().scale(dx) self.set_transform(trans) return trans Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-10-17 01:15:48 UTC (rev 3959) +++ branches/transforms/lib/matplotlib/transforms.py 2007-10-18 14:51:16 UTC (rev 3960) @@ -90,7 +90,7 @@ """ # Shortcut: If self is already invalid, that means its parents # are as well, so we don't need to do anything. - if self._invalid: + if self._invalid or not len(self._parents): return # If we are an affine transform being changed, we can set the @@ -127,7 +127,7 @@ """ return self - def write_graphviz(self, fobj): + def write_graphviz(self, fobj, highlight=[]): """ For debugging purposes. @@ -146,14 +146,22 @@ if root in seen: return seen.add(root) - fobj.write('%s [label="%s"];\n' % - (hash(root), root.__class__.__name__)) + props = {} + label = root.__class__.__name__ + if root._invalid: + label = '[%s]' % label + if root in highlight: + props['style'] = 'bold' if root.is_affine: - fobj.write('%s [style=filled, color=".7 .7 .9"];\n' % - hash(root)) - elif root.is_bbox: - fobj.write('%s [style=filled, color=".9 .9 .7"];\n' % - hash(root)) + props['shape'] = 'parallelogram' + if root.is_bbox: + props['shape'] = 'box' + props['label'] = '"%s"' % label + props = ' '.join(['%s=%s' % (key, val) for key, val in props.items()]) + + fobj.write('%s [%s];\n' % + (hash(root), props)) + for child in root._children: name = '?' for key, val in root.__dict__.items(): @@ -627,20 +635,23 @@ minpos = npy.array([-npy.inf, -npy.inf], npy.float_) if ignore: - self._points = npy.array( + points = npy.array( [[x.min(), y.min()], [x.max(), y.max()]], npy.float_) self._minpos = minpos else: - self._points = npy.array( + points = npy.array( [[min(x.min(), self.xmin), min(y.min(), self.ymin)], [max(x.max(), self.xmax), max(y.max(), self.ymax)]], npy.float_) self._minpos = npy.minimum(minpos, self._minpos) - self.invalidate() + if npy.any(self._points != points): + self._points = points + self.invalidate() + def update_from_data_xy(self, xy, ignore=None): """ Update the bounds of the Bbox based on the passed in data. @@ -695,8 +706,10 @@ def _set_bounds(self, bounds): l, b, w, h = bounds - self._points = npy.array([[l, b], [l+w, b+h]], npy.float_) - self.invalidate() + points = npy.array([[l, b], [l+w, b+h]], npy.float_) + if npy.any(self._points != points): + self._points = points + self.invalidate() bounds = property(BboxBase._get_bounds, _set_bounds) def _get_minpos(self): @@ -725,15 +738,17 @@ of the form: [[xmin, ymin], [xmax, ymax]]. No error checking is performed, as this method is mainly for internal use. """ - self._points = points - self.invalidate() + if npy.any(self._points != points): + self._points = points + self.invalidate() def set(self, other): """ Set this bounding box from the "frozen" bounds of another Bbox. """ - self._points = other.get_points() - self.invalidate() + if npy.any(self._points != other.get_points()): + self._points = other.get_points() + self.invalidate() class TransformedBbox(BboxBase): @@ -1848,8 +1863,6 @@ self._a = a self._b = b self.set_children(a, b) - self._mtx = None - self._affine = None def frozen(self): self._invalid = 0 @@ -1905,14 +1918,11 @@ transform_path_non_affine.__doc__ = Transform.transform_path_non_affine.__doc__ def get_affine(self): - if self._invalid or self._affine is None: - if self._a.is_affine and self._b.is_affine: - self._affine = Affine2D(npy.dot(self._b.get_affine().get_matrix(), - self._a.get_affine().get_matrix())) - else: - self._affine = self._b.get_affine() - self._invalid = 0 - return self._affine + if self._a.is_affine and self._b.is_affine: + return Affine2D(npy.dot(self._b.get_affine().get_matrix(), + self._a.get_affine().get_matrix())) + else: + return self._b.get_affine() get_affine.__doc__ = Transform.get_affine.__doc__ def inverted(self): @@ -2046,7 +2056,6 @@ self._transform = transform self.set_children(transform) self._transformed_path = None - self.get_affine = self._transform.get_affine def get_transformed_path_and_affine(self): """ @@ -2071,8 +2080,10 @@ self._transform.transform_path_non_affine(self._path) self._invalid = 0 return self._transform.transform_path_affine(self._transformed_path) + + def get_affine(self): + return self._transform.get_affine() - def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True): ''' Ensure the endpoints of a range are not too close together. 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: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins