From: <ef...@us...> - 2009-01-10 20:48:56
|
Revision: 6775 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6775&view=rev Author: efiring Date: 2009-01-10 20:48:49 +0000 (Sat, 10 Jan 2009) Log Message: ----------- svnmerge 6773 from v0_98_5_maint Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6754 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6773 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-10 20:44:07 UTC (rev 6774) +++ trunk/matplotlib/CHANGELOG 2009-01-10 20:48:49 UTC (rev 6775) @@ -1,3 +1,5 @@ +2009-01-10 Fix bug in pan/zoom with log coordinates. - EF + 2009-01-10 Applied Michiel's hatch patch for macosx backend and draw_idle patch for qt. Closes sf patched 2497785 and 2468809 - JDH Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773 Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-10 20:44:07 UTC (rev 6774) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-10 20:48:49 UTC (rev 6775) @@ -2402,10 +2402,11 @@ dy = dx alpha = np.power(10.0, (dx, dy)) - start = p.trans_inverse.transform_point((p.x, p.y)) - lim_points = p.lim.get_points() - result = start + alpha * (lim_points - start) - result = mtransforms.Bbox(result) + start = np.array([p.x, p.y]) + oldpoints = p.lim.transformed(p.trans) + newpoints = start + alpha * (oldpoints - start) + result = mtransforms.Bbox(newpoints) \ + .transformed(p.trans_inverse) except OverflowError: warnings.warn('Overflow while panning') return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-10 20:52:20
|
Revision: 6776 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6776&view=rev Author: jdh2358 Date: 2009-01-10 20:52:16 +0000 (Sat, 10 Jan 2009) Log Message: ----------- Merged revisions 6761,6773-6774 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6774 | jdh2358 | 2009-01-10 14:44:07 -0600 (Sat, 10 Jan 2009) | 1 line fixed unit and autoscaling behavior of the ax line/span funcs ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6773 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6774 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-10 20:48:49 UTC (rev 6775) +++ trunk/matplotlib/CHANGELOG 2009-01-10 20:52:16 UTC (rev 6776) @@ -4,6 +4,8 @@ draw_idle patch for qt. Closes sf patched 2497785 and 2468809 - JDH +2009-01-10 Fix bug in pan/zoom with log coordinates. - EF + 2009-01-06 Fix bug in setting of dashed negative contours. - EF 2009-01-06 Be fault tolerant when len(linestyles)>NLev in contour. - MM Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-10 20:48:49 UTC (rev 6775) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-10 20:52:16 UTC (rev 6776) @@ -2830,6 +2830,7 @@ # We need to strip away the units for comparison with # non-unitized bounds + self._process_unit_info( ydata=y, kwargs=kwargs ) yy = self.convert_yunits( y ) scaley = (yy<ymin) or (yy>ymax) @@ -2890,6 +2891,7 @@ # We need to strip away the units for comparison with # non-unitized bounds + self._process_unit_info( xdata=x, kwargs=kwargs ) xx = self.convert_xunits( x ) scalex = (xx<xmin) or (xx>xmax) @@ -2956,6 +2958,7 @@ p.set_transform(trans) p.x_isdata = False self.add_patch(p) + self.autoscale_view(scalex=False) return p axhspan.__doc__ = cbook.dedent(axhspan.__doc__) % martist.kwdocd @@ -3012,6 +3015,7 @@ p.set_transform(trans) p.y_isdata = False self.add_patch(p) + self.autoscale_view(scaley=False) return p axvspan.__doc__ = cbook.dedent(axvspan.__doc__) % martist.kwdocd @@ -3057,9 +3061,11 @@ 'list of Line2D to draw; see API_CHANGES') # We do the conversion first since not all unitized data is uniform + # process the unit information + self._process_unit_info( [xmin, xmax], y, kwargs=kwargs ) y = self.convert_yunits( y ) - xmin = self.convert_xunits( xmin ) - xmax = self.convert_xunits( xmax ) + xmin = self.convert_xunits(xmin) + xmax = self.convert_xunits(xmax) if not iterable(y): y = [y] if not iterable(xmin): xmin = [xmin] @@ -3133,7 +3139,7 @@ 'collections.LineCollection and not a ' 'list of Line2D to draw; see API_CHANGES') - self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs) + self._process_unit_info(xdata=x, ydata=[ymin, ymax], kwargs=kwargs) # We do the conversion first since not all unitized data is uniform x = self.convert_xunits( x ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-01-13 02:45:35
|
Revision: 6782 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6782&view=rev Author: efiring Date: 2009-01-13 02:45:22 +0000 (Tue, 13 Jan 2009) Log Message: ----------- merge 6781 from v0_98_5_maint Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/collections.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6774 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6781 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781 Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-13 02:40:47 UTC (rev 6781) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-13 02:45:22 UTC (rev 6782) @@ -5057,6 +5057,8 @@ } self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) + x = self.convert_xunits(x) + y = self.convert_yunits(y) x, y, s, c = cbook.delete_masked_points(x, y, s, c) Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2009-01-13 02:40:47 UTC (rev 6781) +++ trunk/matplotlib/lib/matplotlib/collections.py 2009-01-13 02:45:22 UTC (rev 6782) @@ -175,8 +175,8 @@ ys = self.convert_yunits(ys) paths.append(mpath.Path(zip(xs, ys), path.codes)) if len(self._offsets): - xs = self.convert_xunits(self._offsets[:0]) - ys = self.convert_yunits(self._offsets[:1]) + xs = self.convert_xunits(self._offsets[:,0]) + ys = self.convert_yunits(self._offsets[:,1]) offsets = zip(xs, ys) offsets = np.asarray(offsets, np.float_) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2009-01-16 16:12:29
|
Revision: 6787 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6787&view=rev Author: jswhit Date: 2009-01-16 16:12:27 +0000 (Fri, 16 Jan 2009) Log Message: ----------- apply Michiel's patch to macosx backend to fix rounding bug - closes sf bug 2508440. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/src/_macosx.m Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-16 15:39:17 UTC (rev 6786) +++ trunk/matplotlib/CHANGELOG 2009-01-16 16:12:27 UTC (rev 6787) @@ -1,3 +1,6 @@ +2009-01-16 Applied Michiel's patch for macosx backend to fix rounding + bug. Closed sf bug 2508440 - JSW + 2009-01-10 Fix bug in pan/zoom with log coordinates. - EF 2009-01-10 Applied Michiel's hatch patch for macosx backend and Modified: trunk/matplotlib/src/_macosx.m =================================================================== --- trunk/matplotlib/src/_macosx.m 2009-01-16 15:39:17 UTC (rev 6786) +++ trunk/matplotlib/src/_macosx.m 2009-01-16 16:12:27 UTC (rev 6787) @@ -17,7 +17,24 @@ #define CGFloat float #endif +/* This is the same as CGAffineTransform, except that the data members are + * doubles rather than CGFloats. + * Matrix structure: + * [ a b 0] + * [ c d 0] + * [ tx ty 1] + */ +typedef struct +{ + double a; + double b; + double c; + double d; + double tx; + double ty; +} AffineTransform; + /* Various NSApplicationDefined event subtypes */ #define STDIN_READY 0 #define SIGINT_CALLED 1 @@ -169,6 +186,19 @@ return 1; } +static AffineTransform +AffineTransformConcat(AffineTransform t1, AffineTransform t2) +{ + AffineTransform t; + t.a = t1.a * t2.a + t1.b * t2.c; + t.b = t1.a * t2.b + t1.b * t2.d; + t.c = t1.c * t2.a + t1.d * t2.c; + t.d = t1.c * t2.b + t1.d * t2.d; + t.tx = t1.tx * t2.a + t1.ty * t2.c + t2.tx; + t.ty = t1.tx * t2.b + t1.ty * t2.d + t2.ty; + return t; +} + static int _init_atsui(void) { OSStatus status; @@ -208,9 +238,10 @@ } static int -_draw_path(CGContextRef cr, PyObject* path, CGAffineTransform affine) +_draw_path(CGContextRef cr, PyObject* path, AffineTransform affine) { - CGPoint point; + double x1, y1, x2, y2, x3, y3; + CGFloat fx1, fy1, fx2, fy2, fx3, fy3; PyObject* vertices = PyObject_GetAttrString(path, "vertices"); if (vertices==NULL) @@ -271,22 +302,23 @@ npy_uint8 code = MOVETO; for (i = 0; i < n; i++) { - point.x = (CGFloat)(*(double*)PyArray_GETPTR2(coordinates, i, 0)); - point.y = (CGFloat)(*(double*)PyArray_GETPTR2(coordinates, i, 1)); - if (isnan(point.x) || isnan(point.y)) + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); + if (isnan(x1) || isnan(y1)) { code = MOVETO; } else { - point = CGPointApplyAffineTransform(point, affine); + fx1 = (CGFloat)(affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat)(affine.b*x1 + affine.d*y1 + affine.ty); switch (code) { case MOVETO: - CGContextMoveToPoint(cr, point.x, point.y); + CGContextMoveToPoint(cr, fx1, fy1); break; case LINETO: - CGContextAddLineToPoint(cr, point.x, point.y); + CGContextAddLineToPoint(cr, fx1, fy1); break; } code = LINETO; @@ -298,7 +330,6 @@ npy_intp i = 0; BOOL was_nan = false; npy_uint8 code; - CGFloat x1, y1, x2, y2, x3, y3; while (i < n) { code = *(npy_uint8*)PyArray_GETPTR1(codelist, i); @@ -315,8 +346,8 @@ { if (code==CURVE3) i++; else if (code==CURVE4) i+=2; - x1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; if (isnan(x1) || isnan(y1)) { @@ -324,17 +355,16 @@ } else { - point.x = x1; - point.y = y1; - point = CGPointApplyAffineTransform(point, affine); - CGContextMoveToPoint(cr, point.x, point.y); + fx1 = (CGFloat) (affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat) (affine.b*x1 + affine.d*y1 + affine.ty); + CGContextMoveToPoint(cr, fx1, fy1); was_nan = false; } } else if (code==MOVETO) { - x1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; if (isnan(x1) || isnan(y1)) { @@ -342,17 +372,16 @@ } else { - point.x = x1; - point.y = y1; - point = CGPointApplyAffineTransform(point, affine); - CGContextMoveToPoint(cr, point.x, point.y); + fx1 = (CGFloat) (affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat) (affine.b*x1 + affine.d*y1 + affine.ty); + CGContextMoveToPoint(cr, fx1, fy1); was_nan = false; } } else if (code==LINETO) { - x1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; if (isnan(x1) || isnan(y1)) { @@ -360,20 +389,19 @@ } else { - point.x = x1; - point.y = y1; - point = CGPointApplyAffineTransform(point, affine); - CGContextAddLineToPoint(cr, point.x, point.y); + fx1 = (CGFloat) (affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat) (affine.b*x1 + affine.d*y1 + affine.ty); + CGContextAddLineToPoint(cr, fx1, fy1); was_nan = false; } } else if (code==CURVE3) { - x1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; - x2 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y2 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x2 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y2 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; if (isnan(x1) || isnan(y1) || isnan(x2) || isnan(y2)) { @@ -381,30 +409,24 @@ } else { - point.x = x1; - point.y = y1; - point = CGPointApplyAffineTransform(point, affine); - x1 = point.x; - y1 = point.y; - point.x = x2; - point.y = y2; - point = CGPointApplyAffineTransform(point, affine); - x2 = point.x; - y2 = point.y; - CGContextAddQuadCurveToPoint(cr, x1, y1, x2, y2); + fx1 = (CGFloat) (affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat) (affine.b*x1 + affine.d*y1 + affine.ty); + fx2 = (CGFloat) (affine.a*x2 + affine.c*y2 + affine.tx); + fy2 = (CGFloat) (affine.b*x2 + affine.d*y2 + affine.ty); + CGContextAddQuadCurveToPoint(cr, fx1, fy1, fx2, fy2); was_nan = false; } } else if (code==CURVE4) { - x1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y1 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x1 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y1 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; - x2 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y2 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x2 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y2 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; - x3 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - y3 = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); + x3 = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y3 = *(double*)PyArray_GETPTR2(coordinates, i, 1); i++; if (isnan(x1) || isnan(y1) || isnan(x2) || isnan(y2) || isnan(x3) || isnan(y3)) { @@ -412,22 +434,13 @@ } else { - point.x = x1; - point.y = y1; - point = CGPointApplyAffineTransform(point, affine); - x1 = point.x; - y1 = point.y; - point.x = x2; - point.y = y2; - point = CGPointApplyAffineTransform(point, affine); - x2 = point.x; - y2 = point.y; - point.x = x3; - point.y = y3; - point = CGPointApplyAffineTransform(point, affine); - x3 = point.x; - y3 = point.y; - CGContextAddCurveToPoint(cr, x1, y1, x2, y2, x3, y3); + fx1 = (CGFloat) (affine.a*x1 + affine.c*y1 + affine.tx); + fy1 = (CGFloat) (affine.b*x1 + affine.d*y1 + affine.ty); + fx2 = (CGFloat) (affine.a*x2 + affine.c*y2 + affine.tx); + fy2 = (CGFloat) (affine.b*x2 + affine.d*y2 + affine.ty); + fx3 = (CGFloat) (affine.a*x3 + affine.c*y3 + affine.tx); + fy3 = (CGFloat) (affine.b*x3 + affine.d*y3 + affine.ty); + CGContextAddCurveToPoint(cr, fx1, fy1, fx2, fy2, fx3, fy3); was_nan = false; } } @@ -442,8 +455,7 @@ static void _draw_hatch (void *info, CGContextRef cr) { PyObject* hatchpath = (PyObject*)info; - CGAffineTransform affine = CGAffineTransformMakeScale(HATCH_SIZE, HATCH_SIZE); - + AffineTransform affine = {HATCH_SIZE, 0, 0, HATCH_SIZE, 0, 0}; int n = _draw_path(cr, hatchpath, affine); if (n < 0) { @@ -1061,9 +1073,9 @@ } static int -_convert_affine_transform(PyObject* object, CGAffineTransform* transform) -/* Reads a Numpy affine transformation matrix and returns - * a CGAffineTransform. +_convert_affine_transform(PyObject* object, AffineTransform* transform) +/* Reads a Numpy affine transformation matrix and returns an + * AffineTransform structure */ { PyArrayObject* matrix = NULL; @@ -1093,17 +1105,16 @@ char* row0 = PyArray_BYTES(matrix); char* row1 = row0 + stride0; - double a = *(double*)(row0); + transform->a = *(double*)(row0); row0 += stride1; - double c = *(double*)(row0); + transform->c = *(double*)(row0); row0 += stride1; - double e = *(double*)(row0); - double b = *(double*)(row1); + transform->tx = *(double*)(row0); + transform->b = *(double*)(row1); row1 += stride1; - double d = *(double*)(row1); + transform->d = *(double*)(row1); row1 += stride1; - double f = *(double*)(row1); - *transform = CGAffineTransformMake(a, b, c, d, e, f); + transform->ty = *(double*)(row1); Py_DECREF(matrix); return 1; @@ -1133,7 +1144,7 @@ if(rgbFace==Py_None) rgbFace = NULL; - CGAffineTransform affine; + AffineTransform affine; ok = _convert_affine_transform(transform, &affine); if (!ok) return NULL; @@ -1223,6 +1234,7 @@ int ok; float r, g, b; + double x, y; CGContextRef cr = self->cr; @@ -1251,11 +1263,11 @@ CGContextSetRGBFillColor(cr, r, g, b, 1.0); } - CGAffineTransform affine; + AffineTransform affine; ok = _convert_affine_transform(transform, &affine); if (!ok) return NULL; - CGAffineTransform marker_affine; + AffineTransform marker_affine; ok = _convert_affine_transform(marker_transform, &marker_affine); if (!ok) return NULL; @@ -1285,17 +1297,15 @@ npy_intp i; npy_intp n = PyArray_DIM(coordinates, 0); - CGPoint point; - CGAffineTransform t; + AffineTransform t; int m = 0; for (i = 0; i < n; i++) { - point.x = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 0)); - point.y = (CGFloat) (*(double*)PyArray_GETPTR2(coordinates, i, 1)); - point = CGPointApplyAffineTransform(point, affine); + x = *(double*)PyArray_GETPTR2(coordinates, i, 0); + y = *(double*)PyArray_GETPTR2(coordinates, i, 1); t = marker_affine; - t.tx += point.x; - t.ty += point.y; + t.tx += affine.a*x + affine.c*y + affine.tx; + t.ty += affine.b*x + affine.d*y + affine.ty; m = _draw_path(cr, marker_path, t); if (m > 0) @@ -1391,10 +1401,10 @@ CGContextSaveGState(cr); - CGAffineTransform transform; - CGAffineTransform master_transform; - CGAffineTransform offset_transform; - CGAffineTransform* transforms = NULL; + AffineTransform transform; + AffineTransform master_transform; + AffineTransform offset_transform; + AffineTransform* transforms = NULL; if (!_convert_affine_transform(master_transform_obj, &master_transform)) return NULL; if (!_convert_affine_transform(offset_transform_obj, &offset_transform)) return NULL; @@ -1496,18 +1506,18 @@ /* Convert all of the transforms up front */ if (Ntransforms > 0) { - transforms = malloc(Ntransforms*sizeof(CGAffineTransform)); + transforms = malloc(Ntransforms*sizeof(AffineTransform)); if (!transforms) goto error; for (i = 0; i < Ntransforms; i++) { PyObject* transform_obj = PySequence_ITEM(transforms_obj, i); if(!_convert_affine_transform(transform_obj, &transforms[i])) goto error; - transforms[i] = CGAffineTransformConcat(transforms[i], master_transform); + transforms[i] = AffineTransformConcat(transforms[i], master_transform); } } - CGPoint offset; PyObject* path; + double x, y; /* Preset graphics context properties if possible */ if (Naa==1) @@ -1574,11 +1584,10 @@ if (Noffsets) { - offset.x = (CGFloat) (*(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0)); - offset.y = (CGFloat) (*(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1)); - offset = CGPointApplyAffineTransform(offset, offset_transform); - transform.tx += offset.x; - transform.ty += offset.y; + x = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0); + y = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1); + transform.tx += offset_transform.a*x + offset_transform.c*y + offset_transform.tx; + transform.ty += offset_transform.b*x + offset_transform.d*y + offset_transform.ty; } if (Naa > 1) @@ -1703,9 +1712,9 @@ PyArrayObject* offsets = NULL; PyArrayObject* facecolors = NULL; - CGAffineTransform transform; - CGAffineTransform master_transform; - CGAffineTransform offset_transform; + AffineTransform transform; + AffineTransform master_transform; + AffineTransform offset_transform; if (!_convert_affine_transform(master_transform_obj, &master_transform)) return NULL; @@ -1772,8 +1781,6 @@ size_t iw = 0; size_t ih = 0; - CGPoint offset; - /* Preset graphics context properties if possible */ if (antialiased) CGContextSetShouldAntialias(cr, true); else CGContextSetShouldAntialias(cr, false); @@ -1798,6 +1805,7 @@ CGContextSetRGBStrokeColor(cr, 0, 0, 0, 1); } + double x, y; for (ih = 0; ih < meshHeight; ih++) { for (iw = 0; iw < meshWidth; iw++, i++) @@ -1807,35 +1815,38 @@ if (Noffsets) { - offset.x = (CGFloat) (*(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0)); - offset.y = (CGFloat) (*(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1)); - offset = CGPointApplyAffineTransform(offset, offset_transform); - transform.tx += offset.x; - transform.ty += offset.y; + x = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0); + y = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1); + transform.tx += offset_transform.a*x + offset_transform.c*y + offset_transform.tx; + transform.ty += offset_transform.b*x + offset_transform.d*y + offset_transform.ty; } - CGPoint p; + double x, y; CGPoint points[4]; - p.x = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih, iw, 0)); - p.y = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih, iw, 1)); - if (isnan(p.x) || isnan(p.y)) continue; - points[0] = CGPointApplyAffineTransform(p, transform); + x = *(double*)PyArray_GETPTR3(coordinates, ih, iw, 0); + y = *(double*)PyArray_GETPTR3(coordinates, ih, iw, 1); + if (isnan(x) || isnan(y)) continue; + points[0].x = (CGFloat)(transform.a*x + transform.c*y + transform.tx); + points[0].y = (CGFloat)(transform.b*x + transform.d*y + transform.ty); - p.x = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih, iw+1, 0)); - p.y = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih, iw+1, 1)); - if (isnan(p.x) || isnan(p.y)) continue; - points[1] = CGPointApplyAffineTransform(p, transform); + x = *(double*)PyArray_GETPTR3(coordinates, ih, iw+1, 0); + y = *(double*)PyArray_GETPTR3(coordinates, ih, iw+1, 1); + if (isnan(x) || isnan(y)) continue; + points[1].x = (CGFloat)(transform.a*x + transform.c*y + transform.tx); + points[1].y = (CGFloat)(transform.b*x + transform.d*y + transform.ty); - p.x = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih+1, iw+1, 0)); - p.y = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih+1, iw+1, 1)); - if (isnan(p.x) || isnan(p.y)) continue; - points[2] = CGPointApplyAffineTransform(p, transform); + x = *(double*)PyArray_GETPTR3(coordinates, ih+1, iw+1, 0); + y = *(double*)PyArray_GETPTR3(coordinates, ih+1, iw+1, 1); + if (isnan(x) || isnan(y)) continue; + points[2].x = (CGFloat)(transform.a*x + transform.c*y + transform.tx); + points[2].y = (CGFloat)(transform.b*x + transform.d*y + transform.ty); - p.x = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih+1, iw, 0)); - p.y = (CGFloat)(*(double*)PyArray_GETPTR3(coordinates, ih+1, iw, 1)); - if (isnan(p.x) || isnan(p.y)) continue; - points[3] = CGPointApplyAffineTransform(p, transform); + x = *(double*)PyArray_GETPTR3(coordinates, ih+1, iw, 0); + y = *(double*)PyArray_GETPTR3(coordinates, ih+1, iw, 1); + if (isnan(x) || isnan(y)) continue; + points[3].x = (CGFloat)(transform.a*x + transform.c*y + transform.tx); + points[3].y = (CGFloat)(transform.b*x + transform.d*y + transform.ty); CGContextMoveToPoint(cr, points[3].x, points[3].y); CGContextAddLines(cr, points, 4); @@ -2491,7 +2502,7 @@ if (!_clip(cr, cliprect)) ok = false; else if (clippath!=Py_None) { - CGAffineTransform transform; + AffineTransform transform; if (!_convert_affine_transform(clippath_transform, &transform)) { ok = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-16 17:06:41
|
Revision: 6790 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6790&view=rev Author: jdh2358 Date: 2009-01-16 17:06:38 +0000 (Fri, 16 Jan 2009) Log Message: ----------- added custom colormap from list func Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-16 16:25:28 UTC (rev 6789) +++ trunk/matplotlib/CHANGELOG 2009-01-16 17:06:38 UTC (rev 6790) @@ -1,3 +1,7 @@ +2009-11-16 Added helper function LinearSegmentedColormap.from_list to + facilitate building simple custom colomaps. See + examples/pylab_examples/custom_cmap_fromlist.py - JDH + 2009-01-16 Applied Michiel's patch for macosx backend to fix rounding bug. Closed sf bug 2508440 - JSW Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2009-01-16 16:25:28 UTC (rev 6789) +++ trunk/matplotlib/lib/matplotlib/colors.py 2009-01-16 17:06:38 UTC (rev 6790) @@ -611,7 +611,27 @@ self._isinit = True self._set_extremes() + @staticmethod + def from_list(name, colors, N=256): + """ + Make a linear segmented colormap with *name* from a sequence + of *colors* which evenly transitions from colors[0] at val=1 + to colors[-1] at val=1. N is the number of rgb quantization + levels. + """ + ncolors = len(colors) + vals = np.linspace(0., 1., ncolors) + + cdict = dict(red=[], green=[], blue=[]) + for val, color in zip(vals, colors): + r,g,b = colorConverter.to_rgb(color) + cdict['red'].append((val, r, r)) + cdict['green'].append((val, g, g)) + cdict['blue'].append((val, b, b)) + + return LinearSegmentedColormap(name, cdict, N) + class ListedColormap(Colormap): """Colormap object generated from a list of colors. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-01-16 18:16:46
|
Revision: 6791 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6791&view=rev Author: astraw Date: 2009-01-16 18:16:40 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Bugfix of C typedef of MPL_Int64 failing on WinXP64 Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/src/MPL_isnan.h Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-16 17:06:38 UTC (rev 6790) +++ trunk/matplotlib/CHANGELOG 2009-01-16 18:16:40 UTC (rev 6791) @@ -1,3 +1,7 @@ +2009-11-16 Bugfix of C typedef of MPL_Int64 that was failing on + Windows XP 64 bit, as reported by George Goussard on numpy + mailing list. - ADS + 2009-11-16 Added helper function LinearSegmentedColormap.from_list to facilitate building simple custom colomaps. See examples/pylab_examples/custom_cmap_fromlist.py - JDH Modified: trunk/matplotlib/src/MPL_isnan.h =================================================================== --- trunk/matplotlib/src/MPL_isnan.h 2009-01-16 17:06:38 UTC (rev 6790) +++ trunk/matplotlib/src/MPL_isnan.h 2009-01-16 18:16:40 UTC (rev 6791) @@ -12,19 +12,6 @@ #include <stdint.h> #endif -#if defined(SIZEOF_VOID_P) -#if SIZEOF_VOID_P == 8 -#define MPL_LP64 1 -#else -#define MPL_LP64 0 -#endif -#else -#define MPL_LP64 0 -#endif - -#if MPL_LP64 -typedef long int MPL_Int64; -#else /* 32-bit platforms */ #if defined(_MSC_VER) typedef __int64 MPL_Int64; #else @@ -34,7 +21,6 @@ typedef long long MPL_Int64; #endif #endif -#endif #if !defined(MPL_U64) #define MPL_U64(u) (* (MPL_Int64 *) &(u) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-16 18:56:21
|
Revision: 6796 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6796&view=rev Author: jdh2358 Date: 2009-01-16 18:56:11 +0000 (Fri, 16 Jan 2009) Log Message: ----------- cleaned up svn merge from isnan fix Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6781 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6792 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ry...@us...> - 2009-01-16 20:26:48
|
Revision: 6798 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6798&view=rev Author: ryanmay Date: 2009-01-16 20:26:39 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Fix an infinite recursion in the unit registry when trying to find a converter for a sequence of strings. Add a test for this to unit/nose_tests.py Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/units.py trunk/matplotlib/unit/nose_tests.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-16 20:06:55 UTC (rev 6797) +++ trunk/matplotlib/CHANGELOG 2009-01-16 20:26:39 UTC (rev 6798) @@ -1,8 +1,12 @@ -2009-11-16 Bugfix of C typedef of MPL_Int64 that was failing on +2009-01-16 Fix an infinite recursion in the unit registry when searching + for a converter for a sequence of strings. Add a corresponding + test. - RM + +2009-01-16 Bugfix of C typedef of MPL_Int64 that was failing on Windows XP 64 bit, as reported by George Goussard on numpy mailing list. - ADS -2009-11-16 Added helper function LinearSegmentedColormap.from_list to +2009-01-16 Added helper function LinearSegmentedColormap.from_list to facilitate building simple custom colomaps. See examples/pylab_examples/custom_cmap_fromlist.py - JDH Modified: trunk/matplotlib/lib/matplotlib/units.py =================================================================== --- trunk/matplotlib/lib/matplotlib/units.py 2009-01-16 20:06:55 UTC (rev 6797) +++ trunk/matplotlib/lib/matplotlib/units.py 2009-01-16 20:26:39 UTC (rev 6798) @@ -44,7 +44,7 @@ """ import numpy as np -from matplotlib.cbook import iterable, is_numlike +from matplotlib.cbook import iterable, is_numlike, is_string_like class AxisInfo: 'information to support default axis labeling and tick labeling' @@ -127,7 +127,10 @@ if classx is not None: converter = self.get(classx) - if converter is None and iterable(x): + # Check explicity for strings here because they would otherwise + # lead to an infinite recursion, because a single character will + # pass the iterable() check. + if converter is None and iterable(x) and not is_string_like(x): # if this is anything but an object array, we'll assume # there are no custom units if isinstance(x, np.ndarray) and x.dtype != np.object: Modified: trunk/matplotlib/unit/nose_tests.py =================================================================== --- trunk/matplotlib/unit/nose_tests.py 2009-01-16 20:06:55 UTC (rev 6797) +++ trunk/matplotlib/unit/nose_tests.py 2009-01-16 20:26:39 UTC (rev 6798) @@ -40,6 +40,17 @@ fig.canvas.draw() plt.close(fig) +def test_units_strings(): + # Make sure passing in sequences of strings doesn't cause the unit + # conversion registry to recurse infinitely + Id = ['50', '100', '150', '200', '250'] + pout = ['0', '7.4', '11.4', '14.2', '16.3'] + fig = plt.figure() + ax = fig.add_subplot(111) + ax.plot(Id, pout) + fig.canvas.draw() + plt.close(fig) + if __name__=='__main__': nose.runmodule(argv=['-s','--with-doctest'], exit=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-16 21:24:14
|
Revision: 6801 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6801&view=rev Author: jdh2358 Date: 2009-01-16 21:24:01 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Merged revisions 6800 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6800 | jdh2358 | 2009-01-16 13:21:17 -0800 (Fri, 16 Jan 2009) | 1 line fixed get_interpolation / get_resample for AxesImage ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6792 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6800 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2009-01-16 21:21:17 UTC (rev 6800) +++ trunk/matplotlib/lib/matplotlib/image.py 2009-01-16 21:24:01 UTC (rev 6801) @@ -348,10 +348,16 @@ self._interpolation = s def set_resample(self, v): + """ + set whether or not image resampling is used + + ACCEPTS: True|False + """ if v is None: v = rcParams['image.resample'] self._resample = v - def get_interpolation(self): + def get_resample(self): + 'return the image resample boolean' return self._resample def get_extent(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-01-17 05:47:45
|
Revision: 6803 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6803&view=rev Author: efiring Date: 2009-01-17 05:47:42 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Merge 6802 from 98.5 maintenance Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/cbook.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6800 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6802 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-17 04:22:07 UTC (rev 6802) +++ trunk/matplotlib/CHANGELOG 2009-01-17 05:47:42 UTC (rev 6803) @@ -1,3 +1,6 @@ +2009-01-16 Fix bug in is_string_like so it doesn't raise an + unnecessary exception. - EF + 2009-01-16 Fix an infinite recursion in the unit registry when searching for a converter for a sequence of strings. Add a corresponding test. - RM @@ -13,8 +16,6 @@ 2009-01-16 Applied Michiel's patch for macosx backend to fix rounding bug. Closed sf bug 2508440 - JSW -2009-01-10 Fix bug in pan/zoom with log coordinates. - EF - 2009-01-10 Applied Michiel's hatch patch for macosx backend and draw_idle patch for qt. Closes sf patched 2497785 and 2468809 - JDH Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2009-01-17 04:22:07 UTC (rev 6802) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2009-01-17 05:47:42 UTC (rev 6803) @@ -275,7 +275,7 @@ else: return False try: obj + '' - except (TypeError, ValueError): return False + except: return False return True def is_sequence_of_strings(obj): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2009-01-17 10:28:52
|
Revision: 6804 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6804&view=rev Author: leejjoon Date: 2009-01-17 10:28:48 +0000 (Sat, 17 Jan 2009) Log Message: ----------- bbox_inches option for savefig Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/transforms.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-17 05:47:42 UTC (rev 6803) +++ trunk/matplotlib/CHANGELOG 2009-01-17 10:28:48 UTC (rev 6804) @@ -1,3 +1,6 @@ +2009-01-16 Implement bbox_inches option for savefig. If bbox_inches is + "tight", try to determine the tight bounding box. - JJL + 2009-01-16 Fix bug in is_string_like so it doesn't raise an unnecessary exception. - EF Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-17 05:47:42 UTC (rev 6803) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-17 10:28:48 UTC (rev 6804) @@ -33,6 +33,9 @@ import matplotlib.path as path from matplotlib import rcParams +from matplotlib.transforms import Bbox, TransformedBbox, Affine2D +import cStringIO + class RendererBase: """An abstract base class to handle drawing/rendering operations. @@ -1419,6 +1422,28 @@ self.figure.set_facecolor(facecolor) self.figure.set_edgecolor(edgecolor) + bbox_inches = kwargs.pop("bbox_inches", None) + + if bbox_inches: + # call adjust_bbox to save only the given area + if bbox_inches == "tight": + # save the figure to estimate the bounding box + result = getattr(self, method_name)( + cStringIO.StringIO(), + dpi=dpi, + facecolor=facecolor, + edgecolor=edgecolor, + orientation=orientation, + **kwargs) + renderer = self.figure._cachedRenderer + bbox_inches = self.figure.get_tightbbox(renderer) + pad = kwargs.pop("pad_inches", 0.1) + bbox_inches = bbox_inches.padded(pad) + + restore_bbox = self._adjust_bbox(self.figure, format, + bbox_inches) + + try: result = getattr(self, method_name)( filename, @@ -1428,6 +1453,9 @@ orientation=orientation, **kwargs) finally: + if bbox_inches and restore_bbox: + restore_bbox() + self.figure.dpi = origDPI self.figure.set_facecolor(origfacecolor) self.figure.set_edgecolor(origedgecolor) @@ -1435,6 +1463,91 @@ #self.figure.canvas.draw() ## seems superfluous return result + + def _adjust_bbox(self, fig, format, bbox_inches): + """ + Temporarily adjust the figure so that only the specified area + (bbox_inches) is saved. + + It modifies fig.bbox, fig.bbox_inches, + fig.transFigure._boxout, and fig.patch. While the figure size + changes, the scale of the original figure is conserved. A + function whitch restores the original values are returned. + """ + + origBbox = fig.bbox + origBboxInches = fig.bbox_inches + _boxout = fig.transFigure._boxout + + def restore_bbox(): + fig.bbox = origBbox + fig.bbox_inches = origBboxInches + fig.transFigure._boxout = _boxout + fig.transFigure.invalidate() + fig.patch.set_bounds(0, 0, 1, 1) + + if format in ["png", "raw", "rgba"]: + self._adjust_bbox_png(fig, bbox_inches) + return restore_bbox + elif format in ["pdf", "eps"]: + self._adjust_bbox_pdf(fig, bbox_inches) + return restore_bbox + else: + warnings.warn("bbox_inches option for %s backend is not implemented yet." % (format)) + return None + + + def _adjust_bbox_png(self, fig, bbox_inches): + """ + _adjust_bbox for png (Agg) format + """ + + tr = fig.dpi_scale_trans + + _bbox = TransformedBbox(bbox_inches, + tr) + x0, y0 = _bbox.x0, _bbox.y0 + fig.bbox_inches = Bbox.from_bounds(0, 0, + bbox_inches.width, + bbox_inches.height) + + x0, y0 = _bbox.x0, _bbox.y0 + w1, h1 = fig.bbox.width, fig.bbox.height + self.figure.transFigure._boxout = Bbox.from_bounds(-x0, -y0, + w1, h1) + self.figure.transFigure.invalidate() + + fig.bbox = TransformedBbox(fig.bbox_inches, tr) + + fig.patch.set_bounds(x0/w1, y0/h1, + fig.bbox.width/w1, fig.bbox.height/h1) + + + def _adjust_bbox_pdf(self, fig, bbox_inches): + """ + _adjust_bbox for pdf & eps format + """ + + tr = Affine2D().scale(72) + + _bbox = TransformedBbox(bbox_inches, tr) + + fig.bbox_inches = Bbox.from_bounds(0, 0, + bbox_inches.width, + bbox_inches.height) + x0, y0 = _bbox.x0, _bbox.y0 + f = 72. / fig.dpi + w1, h1 = fig.bbox.width*f, fig.bbox.height*f + self.figure.transFigure._boxout = Bbox.from_bounds(-x0, -y0, + w1, h1) + self.figure.transFigure.invalidate() + + fig.bbox = TransformedBbox(fig.bbox_inches, tr) + + fig.patch.set_bounds(x0/w1, y0/h1, + fig.bbox.width/w1, fig.bbox.height/h1) + + def get_default_filetype(self): raise NotImplementedError Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2009-01-17 05:47:42 UTC (rev 6803) +++ trunk/matplotlib/lib/matplotlib/figure.py 2009-01-17 10:28:48 UTC (rev 6804) @@ -33,6 +33,7 @@ import matplotlib.cbook as cbook + class SubplotParams: """ A class to hold the parameters for a subplot @@ -971,6 +972,16 @@ a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function. + + *bbox_inches*: + Bbox in inches. Only the given portion of the figure is + saved. If 'tight', try to figure out the tight bbox of + the figure. + + *pad_inches*: + Amount of padding around the figure when bbox_inches is + 'tight'. + """ for key in ('dpi', 'facecolor', 'edgecolor'): @@ -1091,6 +1102,41 @@ return blocking_input(timeout=timeout) + + def get_tightbbox(self, renderer): + """ + Return a (tight) bounding box of the figure in inches. + + It only accounts axes title, axis labels, and axis + ticklabels. Needs improvement. + """ + + artists = [] + bb = [] + for ax in self.axes: + + artists.append(ax.xaxis.label) + artists.append(ax.yaxis.label) + artists.append(ax.title) + artists.append(ax) + + bbx1, bbx2 = ax.xaxis.get_ticklabel_extents(renderer) + bby1, bby2 = ax.yaxis.get_ticklabel_extents(renderer) + bb.extend([bbx1, bbx2, bby1, bby2]) + + + bb.extend([c.get_window_extent(renderer) for c in artists \ + if c.get_visible()]) + + _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) + + bbox_inches = TransformedBbox(_bbox, + Affine2D().scale(1./self.dpi)) + + return bbox_inches + + + def figaspect(arg): """ Create a figure with specified aspect ratio. If *arg* is a number, Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2009-01-17 05:47:42 UTC (rev 6803) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2009-01-17 10:28:48 UTC (rev 6804) @@ -635,7 +635,7 @@ Return a new :class:`Bbox` that is padded on all four sides by the given value. """ - points = self._points + points = self.get_points() return Bbox(points + [[-p, -p], [p, p]]) def translated(self, tx, ty): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2009-01-18 00:12:49
|
Revision: 6806 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6806&view=rev Author: mdboom Date: 2009-01-18 00:12:15 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Merged revisions 6805 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6805 | mdboom | 2009-01-17 19:10:21 -0500 (Sat, 17 Jan 2009) | 1 line Trivial change to test svnmerge ........ Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6802 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6805 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-01-19 18:11:40
|
Revision: 6810 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6810&view=rev Author: efiring Date: 2009-01-19 18:11:35 +0000 (Mon, 19 Jan 2009) Log Message: ----------- Merged 6809 from v0_98_5_maint Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6805 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6809 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-19 18:06:15 UTC (rev 6809) +++ trunk/matplotlib/CHANGELOG 2009-01-19 18:11:35 UTC (rev 6810) @@ -1,3 +1,5 @@ +2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF + 2009-01-16 Implement bbox_inches option for savefig. If bbox_inches is "tight", try to determine the tight bounding box. - JJL Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-01-19 18:06:15 UTC (rev 6809) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-01-19 18:11:35 UTC (rev 6810) @@ -489,7 +489,8 @@ self.vbox.destroy() self.window.destroy() self.canvas.destroy() - self.toolbar.destroy() + if self.toolbar: + self.toolbar.destroy() self.__dict__.clear() if Gcf.get_num_fig_managers()==0 and \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-01-20 02:13:01
|
Revision: 6812 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6812&view=rev Author: efiring Date: 2009-01-20 02:08:37 +0000 (Tue, 20 Jan 2009) Log Message: ----------- Merge r6811 from v0_98_5_maint Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/quiver.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6809 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6811 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-20 02:03:42 UTC (rev 6811) +++ trunk/matplotlib/CHANGELOG 2009-01-20 02:08:37 UTC (rev 6812) @@ -1,3 +1,5 @@ +2009-01-19 Fix bug in quiver argument handling. - EF + 2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF 2009-01-16 Implement bbox_inches option for savefig. If bbox_inches is Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2009-01-20 02:03:42 UTC (rev 6811) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2009-01-20 02:08:37 UTC (rev 6812) @@ -386,14 +386,13 @@ X, Y, U, V, C = [None]*5 args = list(args) if len(args) == 3 or len(args) == 5: - C = ma.asarray(args.pop(-1)).ravel() + C = ma.asarray(args.pop(-1)) V = ma.asarray(args.pop(-1)) U = ma.asarray(args.pop(-1)) - nn = np.shape(U) - nc = nn[0] - nr = 1 - if len(nn) > 1: - nr = nn[1] + if U.ndim == 1: + nr, nc = 1, U.shape[0] + else: + nr, nc = U.shape if len(args) == 2: # remaining after removing U,V,C X, Y = [np.array(a).ravel() for a in args] if len(X) == nc and len(Y) == nr: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-21 19:09:24
|
Revision: 6815 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6815&view=rev Author: jdh2358 Date: 2009-01-21 19:09:15 +0000 (Wed, 21 Jan 2009) Log Message: ----------- changed defaults on acorr and xcorr to norm, usevlines and maxlags=10 Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/doc/api/api_changes.rst trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-21 14:52:26 UTC (rev 6814) +++ trunk/matplotlib/CHANGELOG 2009-01-21 19:09:15 UTC (rev 6815) @@ -1,3 +1,7 @@ +2009-01-21 Changed the defaults of acorr and xcorr to use + usevlines=True, maxlags=10 and normed=True since these are + the best defaults + 2009-01-19 Fix bug in quiver argument handling. - EF 2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF Modified: trunk/matplotlib/doc/api/api_changes.rst =================================================================== --- trunk/matplotlib/doc/api/api_changes.rst 2009-01-21 14:52:26 UTC (rev 6814) +++ trunk/matplotlib/doc/api/api_changes.rst 2009-01-21 19:09:15 UTC (rev 6815) @@ -19,20 +19,24 @@ Changes for 0.98.x ================== + +* Changed the defaults of acorr and xcorr to use usevlines=True, + maxlags=10 and normed=True since these are the best defaults + * Following keyword parameters for :class:`matplotlib.label.Label` are now - deprecated and new set of parameters are introduced. The new parameters - are given as a fraction of the font-size. Also, *scatteryoffsets*, + deprecated and new set of parameters are introduced. The new parameters + are given as a fraction of the font-size. Also, *scatteryoffsets*, *fancybox* and *columnspacing* are added as keyword parameters. ================ ================ Deprecated New ================ ================ - pad borderpad - labelsep labelspacing - handlelen handlelength - handlestextsep handletextpad - axespad borderaxespad - ================ ================ + pad borderpad + labelsep labelspacing + handlelen handlelength + handlestextsep handletextpad + axespad borderaxespad + ================ ================ * Removed the configobj and experiemtnal traits rc support Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-21 14:52:26 UTC (rev 6814) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-21 19:09:15 UTC (rev 6815) @@ -3543,8 +3543,8 @@ """ call signature:: - acorr(x, normed=False, detrend=mlab.detrend_none, usevlines=False, - maxlags=None, **kwargs) + acorr(x, normed=True, detrend=mlab.detrend_none, usevlines=True, + maxlags=10, **kwargs) Plot the autocorrelation of *x*. If *normed* = *True*, normalize the data by the autocorrelation at 0-th lag. *x* is @@ -3602,13 +3602,13 @@ return self.xcorr(x, x, **kwargs) acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd - def xcorr(self, x, y, normed=False, detrend=mlab.detrend_none, - usevlines=False, maxlags=None, **kwargs): + def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, + usevlines=True, maxlags=10, **kwargs): """ call signature:: - xcorr(x, y, normed=False, detrend=mlab.detrend_none, - usevlines=False, **kwargs): + def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, + usevlines=True, maxlags=10, **kwargs): Plot the cross correlation between *x* and *y*. If *normed* = *True*, normalize the data by the cross correlation at 0-th This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-22 02:54:29
|
Revision: 6817 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6817&view=rev Author: jdh2358 Date: 2009-01-22 02:54:23 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Merged revisions 6816 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6816 | jdh2358 | 2009-01-21 20:48:32 -0600 (Wed, 21 Jan 2009) | 1 line fixed a cocoaagg import bug ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6811 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6816 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-22 02:48:32 UTC (rev 6816) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-22 02:54:23 UTC (rev 6817) @@ -29,7 +29,7 @@ import matplotlib from matplotlib.figure import Figure -from matplotlib.backend_bases import FigureManagerBase +from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase from backend_agg import FigureCanvasAgg from matplotlib._pylab_helpers import Gcf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-22 03:12:57
|
Revision: 6819 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6819&view=rev Author: jdh2358 Date: 2009-01-22 03:12:53 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Merged revisions 6818 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6818 | jdh2358 | 2009-01-21 21:06:44 -0600 (Wed, 21 Jan 2009) | 1 line fixed line collections legmarker sf bug 2511280 ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/legend.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6816 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6818 Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2009-01-22 03:06:44 UTC (rev 6818) +++ trunk/matplotlib/lib/matplotlib/legend.py 2009-01-22 03:12:53 UTC (rev 6819) @@ -272,7 +272,7 @@ self._set_artist_props(self.legendPatch) self._drawFrame = True - + # init with null renderer self._init_legend_box(handles, labels) @@ -327,9 +327,9 @@ def findoffset(width, height, xdescent, ydescent): return _findoffset(width, height, xdescent, ydescent, renderer) - + self._legend_box.set_offset(findoffset) - + fontsize = renderer.points_to_pixels(self.fontsize) # if mode == fill, set the width of the legend_box to the @@ -623,8 +623,11 @@ ydata = ((height-descent)/2.)*np.ones(xdata.shape, float) legline.set_data(xdata, ydata) - legline_marker = legline._legmarker - legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)]) + # if a line collection is added, the legmarker attr is + # not set so we don't need to handle it + if hasattr(handle, "_legmarker"): + legline_marker = legline._legmarker + legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)]) elif isinstance(handle, Patch): p = handle @@ -765,7 +768,7 @@ C:"C"} c = anchor_coefs[loc] - + fontsize = renderer.points_to_pixels(self.fontsize) container = parentbbox.padded(-(self.borderaxespad) * fontsize) anchored_box = bbox.anchored(c, container=container) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-24 18:07:38
|
Revision: 6823 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6823&view=rev Author: jdh2358 Date: 2009-01-24 18:07:31 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Merged revisions 6822 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6822 | jdh2358 | 2009-01-24 10:06:02 -0800 (Sat, 24 Jan 2009) | 1 line drop patches containing nan verts ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/patches.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6818 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6822 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2009-01-24 18:06:02 UTC (rev 6822) +++ trunk/matplotlib/lib/matplotlib/patches.py 2009-01-24 18:07:31 UTC (rev 6823) @@ -299,7 +299,8 @@ tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() - renderer.draw_path(gc, tpath, affine, rgbFace) + if not np.isnan(tpath.vertices).any(): + renderer.draw_path(gc, tpath, affine, rgbFace) renderer.close_group('patch') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2009-01-26 14:40:19
|
Revision: 6828 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6828&view=rev Author: mdboom Date: 2009-01-26 14:40:09 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Merged revisions 6827 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6827 | mdboom | 2009-01-26 09:32:42 -0500 (Mon, 26 Jan 2009) | 2 lines Make curves and NaNs play nice together ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/agg_py_path_iterator.h Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6822 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6827 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-26 14:32:42 UTC (rev 6827) +++ trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828) @@ -1,3 +1,5 @@ +2009-01-26 Make curves and NaNs play nice together - MGD + 2009-01-21 Changed the defaults of acorr and xcorr to use usevlines=True, maxlags=10 and normed=True since these are the best defaults Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:32:42 UTC (rev 6827) +++ trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:40:09 UTC (rev 6828) @@ -299,8 +299,7 @@ tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() - if not np.isnan(tpath.vertices).any(): - renderer.draw_path(gc, tpath, affine, rgbFace) + renderer.draw_path(gc, tpath, affine, rgbFace) renderer.close_group('patch') Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:32:42 UTC (rev 6827) +++ trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:40:09 UTC (rev 6828) @@ -213,7 +213,8 @@ if not isfinite(curr_vertices).all(): was_nan = True elif was_nan: - yield curr_vertices[-2:], MOVETO + yield curr_vertices[:2], MOVETO + yield curr_vertices, code was_nan = False else: yield curr_vertices, code Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-26 14:32:42 UTC (rev 6827) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-26 14:40:09 UTC (rev 6828) @@ -15,7 +15,10 @@ PyArrayObject* m_codes; size_t m_iterator; size_t m_total_vertices; + size_t m_ok; bool m_should_simplify; + static const unsigned char num_extra_points_map[16]; + static const unsigned code_map[]; public: PathIterator(const Py::Object& path_obj) : @@ -41,6 +44,7 @@ throw Py::ValueError("Invalid codes array."); if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0)) throw Py::ValueError("Codes array is wrong length"); + m_ok = 0; } m_should_simplify = should_simplify_obj.isTrue(); @@ -53,8 +57,6 @@ Py_XDECREF(m_codes); } - static const unsigned code_map[]; - private: inline void vertex(const unsigned idx, double* x, double* y) { @@ -82,20 +84,86 @@ if (m_iterator >= m_total_vertices) return agg::path_cmd_stop; unsigned code = vertex_with_code(m_iterator++, x, y); - if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) - { - do + if (!m_codes) { + // This is the fast path for when we know we have no curves + if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) { - if (m_iterator < m_total_vertices) + do { - vertex(m_iterator++, x, y); + if (m_iterator < m_total_vertices) + { + vertex(m_iterator++, x, y); + } + else + { + return agg::path_cmd_stop; + } + } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); + return agg::path_cmd_move_to; + } + } + else + { + // This is the slow method for when there might be curves. + + /* If m_ok is 0, we look ahead to see if the next curve + segment has any NaNs. If it does, we skip the whole + thing and return a move_to to the first point of the + next curve segment. This move_to may include NaNs, + which is ok, since in that case, it will always be + followed by another non-NaN move_to before any other + curves are actually drawn. If the current curve + segment doesn't have NaNs, we set the m_ok counter to + the number of points in the curve segment, which will + skip this check for the next N points. + */ + if (m_ok == 0) { + if (code == agg::path_cmd_stop || + code == (agg::path_cmd_end_poly | agg::path_flags_close)) + { + return code; } - else + + size_t num_extra_points = num_extra_points_map[code & 0xF]; + bool has_nan = (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); + for (size_t i = 0; !has_nan && i < num_extra_points; ++i) { - return agg::path_cmd_stop; + double x0, y0; + vertex(m_iterator + i, &x0, &y0); + has_nan = (MPL_notisfinite64(x0) || MPL_notisfinite64(y0)); } - } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); - return agg::path_cmd_move_to; + + if (has_nan) + { + m_iterator += num_extra_points; + if (m_iterator < m_total_vertices) + { + code = vertex_with_code(m_iterator, x, y); + if (code == agg::path_cmd_stop || + code == (agg::path_cmd_end_poly | agg::path_flags_close)) + { + return code; + } + else + { + return agg::path_cmd_move_to; + } + } + else + { + return agg::path_cmd_stop; + } + } + else /* !has_nan */ + { + m_ok = num_extra_points; + return code; + } + } + else /* m_ok != 0 */ + { + m_ok--; + } } return code; @@ -127,6 +195,12 @@ agg::path_cmd_end_poly | agg::path_flags_close }; +const unsigned char PathIterator::num_extra_points_map[] = + {0, 0, 0, 1, + 2, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0}; + #define DEBUG_SIMPLIFY 0 template<class VertexSource> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2009-01-26 16:39:20
|
Revision: 6829 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6829&view=rev Author: leejjoon Date: 2009-01-26 16:39:14 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Improved tight bbox option of the savefig Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828) +++ trunk/matplotlib/CHANGELOG 2009-01-26 16:39:14 UTC (rev 6829) @@ -1,3 +1,5 @@ +2009-01-26 Improved tight bbox option of the savefig. - JJL + 2009-01-26 Make curves and NaNs play nice together - MGD 2009-01-21 Changed the defaults of acorr and xcorr to use Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 14:40:09 UTC (rev 6828) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 16:39:14 UTC (rev 6829) @@ -7377,6 +7377,40 @@ integer=True)) return im + + def get_tightbbox(self, renderer): + """ + return the tight bounding box of the axes. + The dimension of the Bbox in canvas coordinate. + """ + + artists = [] + bb = [] + + artists.append(self) + + if self.title.get_visible(): + artists.append(self.title) + + if self.xaxis.get_visible(): + artists.append(self.xaxis.label) + bbx1, bbx2 = self.xaxis.get_ticklabel_extents(renderer) + bb.extend([bbx1, bbx2]) + if self.yaxis.get_visible(): + artists.append(self.yaxis.label) + bby1, bby2 = self.yaxis.get_ticklabel_extents(renderer) + bb.extend([bby1, bby2]) + + + bb.extend([c.get_window_extent(renderer) for c in artists]) + + _bbox = mtransforms.Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) + + return _bbox + + + + class SubplotBase: """ Base class for subplots, which are :class:`Axes` instances with @@ -7514,6 +7548,8 @@ for label in self.get_yticklabels(): label.set_visible(firstcol) + + _subplot_classes = {} def subplot_class_factory(axes_class=None): # This makes a new class that inherits from SubclassBase and the Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-26 14:40:09 UTC (rev 6828) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-26 16:39:14 UTC (rev 6829) @@ -1479,7 +1479,25 @@ origBboxInches = fig.bbox_inches _boxout = fig.transFigure._boxout + asp_list = [] + locator_list = [] + for ax in fig.axes: + pos = ax.get_position(original=False).frozen() + locator_list.append(ax.get_axes_locator()) + asp_list.append(ax.get_aspect()) + + def _l(a, r, pos=pos): return pos + ax.set_axes_locator(_l) + ax.set_aspect("auto") + + + def restore_bbox(): + + for ax, asp, loc in zip(fig.axes, asp_list, locator_list): + ax.set_aspect(asp) + ax.set_axes_locator(loc) + fig.bbox = origBbox fig.bbox_inches = origBboxInches fig.transFigure._boxout = _boxout Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 14:40:09 UTC (rev 6828) +++ trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 16:39:14 UTC (rev 6829) @@ -1111,23 +1111,11 @@ ticklabels. Needs improvement. """ - artists = [] bb = [] for ax in self.axes: + if ax.get_visible(): + bb.append(ax.get_tightbbox(renderer)) - artists.append(ax.xaxis.label) - artists.append(ax.yaxis.label) - artists.append(ax.title) - artists.append(ax) - - bbx1, bbx2 = ax.xaxis.get_ticklabel_extents(renderer) - bby1, bby2 = ax.yaxis.get_ticklabel_extents(renderer) - bb.extend([bbx1, bbx2, bby1, bby2]) - - - bb.extend([c.get_window_extent(renderer) for c in artists \ - if c.get_visible()]) - _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) bbox_inches = TransformedBbox(_bbox, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-27 13:17:47
|
Revision: 6842 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6842&view=rev Author: jdh2358 Date: 2009-01-27 12:34:49 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Merged revisions 6841 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6841 | jdh2358 | 2009-01-27 06:33:10 -0600 (Tue, 27 Jan 2009) | 1 line fixed set_pickradius bug ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/lines.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6827 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6841 Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2009-01-27 12:33:10 UTC (rev 6841) +++ trunk/matplotlib/lib/matplotlib/lines.py 2009-01-27 12:34:49 UTC (rev 6842) @@ -315,7 +315,7 @@ 'return the pick radius used for containment tests' return self.pickradius - def setpickradius(self,d): + def set_pickradius(self,d): """Sets the pick radius used for containment tests ACCEPTS: float distance in points This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2009-01-29 16:51:17
|
Revision: 6847 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6847&view=rev Author: mdboom Date: 2009-01-29 16:51:12 +0000 (Thu, 29 Jan 2009) Log Message: ----------- Rework the nan-handling/clipping/quantizing/simplification framework so each is an independent part of a pipeline. Expose the C++-implementation of all of this so it can be used from all Python backends. Add rcParam "path.simplify_threshold" to control the threshold of similarity below which vertices will be removed. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/api/quad_bezier.py trunk/matplotlib/examples/pylab_examples/simplification_clipping_test.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/config/mplconfig.py trunk/matplotlib/lib/matplotlib/config/rcsetup.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h trunk/matplotlib/src/_macosx.m trunk/matplotlib/src/_path.cpp trunk/matplotlib/src/agg_py_path_iterator.h Added Paths: ----------- trunk/matplotlib/src/path_converters.h Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/CHANGELOG 2009-01-29 16:51:12 UTC (rev 6847) @@ -1,3 +1,10 @@ +2009-01-29 Rework the nan-handling/clipping/quantizing/simplification + framework so each is an independent part of a pipeline. + Expose the C++-implementation of all of this so it can be + used from all Python backends. Add rcParam + "path.simplify_threshold" to control the threshold of + similarity below which vertices will be removed. + 2009-01-26 Improved tight bbox option of the savefig. - JJL 2009-01-26 Make curves and NaNs play nice together - MGD Modified: trunk/matplotlib/examples/api/quad_bezier.py =================================================================== --- trunk/matplotlib/examples/api/quad_bezier.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/examples/api/quad_bezier.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -3,10 +3,13 @@ import matplotlib.patches as mpatches import matplotlib.pyplot as plt +Path = mpath.Path + fig = plt.figure() ax = fig.add_subplot(111) pp1 = mpatches.PathPatch( - mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)], [1, 3, 3, 5]), + Path([(0, 0), (1, 0), (1, 1), (0, 0)], + [Path.MOVETO, Path.CURVE3, Path.CURVE3, Path.CLOSEPOLY]), fc="none", transform=ax.transData) ax.add_patch(pp1) Modified: trunk/matplotlib/examples/pylab_examples/simplification_clipping_test.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/simplification_clipping_test.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/examples/pylab_examples/simplification_clipping_test.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -1,4 +1,5 @@ from pylab import * +import numpy as np t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) @@ -7,5 +8,51 @@ ylim((-0.20, -0.28)) title('Should see four lines extending from bottom to top') -grid(True) + +figure() + +x = np.array([1.0,2.0,3.0,2.0e5]) +y = np.arange(len(x)) +plot(x,y) +xlim(xmin=2,xmax=6) +title("Should be monotonically increasing") + +figure() + +x = np.array([0.0, 1.0, 0.0, -1.0, 0.0]) +y = np.array([1.0, 0.0, -1.0, 0.0, 1.0]) +plot(x, y) +xlim(xmin=-0.6, xmax=0.6) +ylim(ymin=-0.6, ymax=0.6) +title("Diamond shape, with segments visible in all four corners") + +figure() + +np.random.seed(0) +x = np.random.uniform(size=(5000,)) * 50 + +rcParams['path.simplify'] = True +p1 = plot(x,solid_joinstyle='round',linewidth=2.0) + +path = p1[0].get_path() +transform = p1[0].get_transform() +path = transform.transform_path(path) +simplified = list(path.iter_segments(simplify=(800, 600))) + +title("Original length: %d, simplified length: %d" % (len(path.vertices), len(simplified))) + +figure() + +x = np.sin(np.linspace(0, np.pi * 2.0, 1000)) + np.random.uniform(size=(1000,)) * 0.01 + +rcParams['path.simplify'] = True +p1 = plot(x,solid_joinstyle='round',linewidth=2.0) + +path = p1[0].get_path() +transform = p1[0].get_transform() +path = transform.transform_path(path) +simplified = list(path.iter_segments(simplify=(800, 600))) + +title("Original length: %d, simplified length: %d" % (len(path.vertices), len(simplified))) + show() Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -99,8 +99,7 @@ want to override this method in order to draw the marker only once and reuse it multiple times. """ - tpath = trans.transform_path(path) - for vertices, codes in tpath.iter_segments(): + for vertices, codes in path.iter_segments(trans, simplify=False): if len(vertices): x,y = vertices[-2:] self.draw_path(gc, marker_path, Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -122,8 +122,8 @@ @staticmethod - def convert_path(ctx, tpath): - for points, code in tpath.iter_segments(): + def convert_path(ctx, path, transform): + for points, code in path.iter_segments(transform): if code == Path.MOVETO: ctx.move_to(*points) elif code == Path.LINETO: @@ -145,10 +145,9 @@ ctx = gc.ctx transform = transform + \ Affine2D().scale(1.0, -1.0).translate(0, self.height) - tpath = transform.transform_path(path) ctx.new_path() - self.convert_path(ctx, tpath) + self.convert_path(ctx, path, transform) self._fill_and_stroke(ctx, rgbFace, gc.get_alpha()) @@ -343,8 +342,7 @@ ctx = self.ctx ctx.new_path() affine = affine + Affine2D().scale(1.0, -1.0).translate(0.0, self.renderer.height) - tpath = affine.transform_path(tpath) - RendererCairo.convert_path(ctx, tpath) + RendererCairo.convert_path(ctx, path, affine) ctx.clip() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -415,10 +415,6 @@ self.endStream() self.width, self.height = width, height - if rcParams['path.simplify']: - self.simplify = (width * 72, height * 72) - else: - self.simplify = None contentObject = self.reserveObject('page contents') thePage = { 'Type': Name('Page'), 'Parent': self.pagesObject, @@ -1140,12 +1136,10 @@ self.endStream() @staticmethod - def pathOperations(path, transform, simplify=None): - tpath = transform.transform_path(path) - + def pathOperations(path, transform, clip=None): cmds = [] last_points = None - for points, code in tpath.iter_segments(simplify): + for points, code in path.iter_segments(transform, clip=clip): if code == Path.MOVETO: cmds.extend(points) cmds.append(Op.moveto) @@ -1164,8 +1158,12 @@ last_points = points return cmds - def writePath(self, path, transform): - cmds = self.pathOperations(path, transform, self.simplify) + def writePath(self, path, transform, clip=False): + if clip: + clip = (0.0, 0.0, self.width * 72, self.height * 72) + else: + clip = None + cmds = self.pathOperations(path, transform, clip) self.output(*cmds) def reserveObject(self, name=''): @@ -1282,7 +1280,7 @@ def draw_path(self, gc, path, transform, rgbFace=None): self.check_gc(gc, rgbFace) - stream = self.file.writePath(path, transform) + stream = self.file.writePath(path, transform, rgbFace is None) self.file.output(self.gc.paint()) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): @@ -1292,11 +1290,10 @@ output = self.file.output marker = self.file.markerObject( marker_path, marker_trans, fillp, self.gc._linewidth) - tpath = trans.transform_path(path) output(Op.gsave) lastx, lasty = 0, 0 - for vertices, code in tpath.iter_segments(): + for vertices, code in path.iter_segments(trans, simplify=False): if len(vertices): x, y = vertices[-2:] dx, dy = x - lastx, y - lasty @@ -1796,9 +1793,9 @@ if self._cliprect != cliprect: cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath]) if self._clippath != clippath: + path, affine = clippath.get_transformed_path_and_affine() cmds.extend( - PdfFile.pathOperations( - *clippath.get_transformed_path_and_affine()) + + PdfFile.pathOperations(path, affine) + [Op.clip, Op.endpath]) return cmds Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -150,10 +150,6 @@ self.textcnt = 0 self.psfrag = [] self.imagedpi = imagedpi - if rcParams['path.simplify']: - self.simplify = (width * imagedpi, height * imagedpi) - else: - self.simplify = None # current renderer state (None=uninitialised) self.color = None @@ -428,12 +424,15 @@ # unflip im.flipud_out() - def _convert_path(self, path, transform, simplify=None): - path = transform.transform_path(path) - + def _convert_path(self, path, transform, clip=False): ps = [] last_points = None - for points, code in path.iter_segments(simplify): + if clip: + clip = (0.0, 0.0, self.width * self.imagedpi, + self.height * self.imagedpi) + else: + clip = None + for points, code in path.iter_segments(transform, clip=clip): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: @@ -466,7 +465,7 @@ """ Draws a Path instance using the given affine transform. """ - ps = self._convert_path(path, transform, self.simplify) + ps = self._convert_path(path, transform, clip=(rgbFace is None)) self._draw_ps(ps, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): @@ -494,8 +493,7 @@ ps_cmd.extend(['stroke', 'grestore', '} bind def']) - tpath = trans.transform_path(path) - for vertices, code in tpath.iter_segments(): + for vertices, code in path.iter_segments(trans, simplify=False): if len(vertices): x, y = vertices[-2:] ps_cmd.append("%g %g o" % (x, y)) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -42,10 +42,6 @@ self.width=width self.height=height self._svgwriter = svgwriter - if rcParams['path.simplify']: - self.simplify = (width, height) - else: - self.simplify = None self._groupd = {} if not rcParams['svg.image_inline']: @@ -209,14 +205,16 @@ .scale(1.0, -1.0) .translate(0.0, self.height)) - def _convert_path(self, path, transform, simplify=None): - tpath = transform.transform_path(path) - + def _convert_path(self, path, transform, clip=False): path_data = [] appender = path_data.append path_commands = self._path_commands currpos = 0 - for points, code in tpath.iter_segments(simplify): + if clip: + clip = (0.0, 0.0, self.width, self.height) + else: + clip = None + for points, code in path.iter_segments(transform, clip=clip): if code == Path.CLOSEPOLY: segment = 'z' else: @@ -231,7 +229,7 @@ def draw_path(self, gc, path, transform, rgbFace=None): trans_and_flip = self._make_flip_transform(transform) - path_data = self._convert_path(path, trans_and_flip, self.simplify) + path_data = self._convert_path(path, trans_and_flip, clip=(rgbFace is None)) self._draw_svg_element('path', 'd="%s"' % path_data, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): @@ -252,8 +250,7 @@ write('<g %s>' % clippath) trans_and_flip = self._make_flip_transform(trans) - tpath = trans_and_flip.transform_path(path) - for vertices, code in tpath.iter_segments(): + for vertices, code in path.iter_segments(trans_and_flip, simplify=False): if len(vertices): x, y = vertices[-2:] details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -304,9 +304,9 @@ new_bounds[2], new_bounds[3]) @staticmethod - def convert_path(gfx_ctx, tpath): + def convert_path(gfx_ctx, path, transform): wxpath = gfx_ctx.CreatePath() - for points, code in tpath.iter_segments(): + for points, code in path.iter_segments(transform): if code == Path.MOVETO: wxpath.MoveToPoint(*points) elif code == Path.LINETO: @@ -324,8 +324,7 @@ self.handle_clip_rectangle(gc) gfx_ctx = gc.gfx_ctx transform = transform + Affine2D().scale(1.0, -1.0).translate(0.0, self.height) - tpath = transform.transform_path(path) - wxpath = self.convert_path(gfx_ctx, tpath) + wxpath = self.convert_path(gfx_ctx, path, transform) if rgbFace is not None: gfx_ctx.SetBrush(wx.Brush(gc.get_wxcolour(rgbFace))) gfx_ctx.DrawPath(wxpath) Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -118,6 +118,7 @@ class path(TConfig): simplify = T.false + simplify_threshold = T.float(1.0 / 9.0) class patch(TConfig): linewidth = T.Float(1.0) @@ -442,7 +443,8 @@ 'svg.embed_char_paths' : (self.tconfig.backend.svg, 'embed_char_paths'), # Path properties - 'path.simplify' : (self.tconfig.path, 'simplify') + 'path.simplify' : (self.tconfig.path, 'simplify'), + 'path.simplify_threshold' : (self.tconfig.path, 'simplify_threshold') } def __setitem__(self, key, val): Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -479,7 +479,8 @@ 'svg.embed_char_paths' : [True, validate_bool], # True to save all characters as paths in the SVG 'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate - 'path.simplify' : [True, validate_bool] + 'path.simplify' : [True, validate_bool], + 'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)] } if __name__ == '__main__': Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/path.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -10,7 +10,8 @@ from matplotlib._path import point_in_path, get_path_extents, \ point_in_path_collection, get_path_collection_extents, \ - path_in_path, path_intersects_path, convert_path_to_polygons + path_in_path, path_intersects_path, convert_path_to_polygons, \ + cleanup_path from matplotlib.cbook import simple_linear_interpolation, maxdict from matplotlib import rcParams @@ -65,14 +66,17 @@ """ # Path codes - STOP = 0 # 1 vertex - MOVETO = 1 # 1 vertex - LINETO = 2 # 1 vertex - CURVE3 = 3 # 2 vertices - CURVE4 = 4 # 3 vertices - CLOSEPOLY = 5 # 1 vertex + STOP = 0 # 1 vertex + MOVETO = 1 # 1 vertex + LINETO = 2 # 1 vertex + CURVE3 = 3 # 2 vertices + CURVE4 = 4 # 3 vertices + CLOSEPOLY = 0x4f # 1 vertex - NUM_VERTICES = [1, 1, 1, 2, 3, 1] + NUM_VERTICES = [1, 1, 1, 2, + 3, 1, 1, 1, + 1, 1, 1, 1, + 1, 1, 1, 1] code_type = np.uint8 @@ -113,6 +117,7 @@ self.should_simplify = (rcParams['path.simplify'] and (len(vertices) >= 128 and (codes is None or np.all(codes <= Path.LINETO)))) + self.simplify_threshold = rcParams['path.simplify_threshold'] self.has_nonfinite = not np.isfinite(vertices).all() self.codes = codes self.vertices = vertices @@ -146,31 +151,43 @@ def __len__(self): return len(self.vertices) - def iter_segments(self, simplify=None): + def iter_segments(self, transform=None, remove_nans=True, clip=None, + quantize=False, simplify=None, curves=True): """ Iterates over all of the curve segments in the path. Each iteration returns a 2-tuple (*vertices*, *code*), where *vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is one of the :class:`Path` codes. - If *simplify* is provided, it must be a tuple (*width*, - *height*) defining the size of the figure, in native units - (e.g. pixels or points). Simplification implies both removing - adjacent line segments that are very close to parallel, and - removing line segments outside of the figure. The path will - be simplified *only* if :attr:`should_simplify` is True, which - is determined in the constructor by this criteria: + Additionally, this method can provide a number of standard + cleanups and conversions to the path. - - No curves - - More than 128 vertices + *transform*: if not None, the given affine transformation will + be applied to the path. + + *remove_nans*: if True, will remove all NaNs from the path and + insert MOVETO commands to skip over them. + + *clip*: if not None, must be a four-tuple (x1, y1, x2, y2) + defining a rectangle in which to clip the path. + + *quantize*: if None, auto-quantize. If True, force quantize, + and if False, don't quantize. + + *simplify*: if True, perform simplification, to remove + vertices that do not affect the appearance of the path. If + False, perform no simplification. If None, use the + should_simplify member variable. + + *curves*: If True, curve segments will be returned as curve + segments. If False, all curves will be converted to line + segments. """ vertices = self.vertices if not len(vertices): return codes = self.codes - len_vertices = len(vertices) - isfinite = np.isfinite NUM_VERTICES = self.NUM_VERTICES MOVETO = self.MOVETO @@ -178,47 +195,20 @@ CLOSEPOLY = self.CLOSEPOLY STOP = self.STOP - if simplify is not None and self.should_simplify: - polygons = self.to_polygons(None, *simplify) - for vertices in polygons: - yield vertices[0], MOVETO - for v in vertices[1:]: - yield v, LINETO - elif codes is None: - if self.has_nonfinite: - next_code = MOVETO - for v in vertices: - if np.isfinite(v).all(): - yield v, next_code - next_code = LINETO - else: - next_code = MOVETO + vertices, codes = cleanup_path(self, transform, remove_nans, clip, + quantize, simplify, curves) + len_vertices = len(vertices) + + i = 0 + while i < len_vertices: + code = codes[i] + if code == STOP: + return else: - yield vertices[0], MOVETO - for v in vertices[1:]: - yield v, LINETO - else: - i = 0 - was_nan = False - while i < len_vertices: - code = codes[i] - if code == CLOSEPOLY: - yield [], code - i += 1 - elif code == STOP: - return - else: - num_vertices = NUM_VERTICES[int(code)] - curr_vertices = vertices[i:i+num_vertices].flatten() - if not isfinite(curr_vertices).all(): - was_nan = True - elif was_nan: - yield curr_vertices[:2], MOVETO - yield curr_vertices, code - was_nan = False - else: - yield curr_vertices, code - i += num_vertices + num_vertices = NUM_VERTICES[int(code) & 0xf] + curr_vertices = vertices[i:i+num_vertices].flatten() + yield curr_vertices, code + i += num_vertices def transformed(self, transform): """ Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2009-01-29 16:51:12 UTC (rev 6847) @@ -520,6 +520,7 @@ 'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate 'path.simplify' : [True, validate_bool], + 'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)], 'agg.path.chunksize' : [0, validate_int] # 0 to disable chunking; # recommend about 20000 to # enable. Experimental. Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/matplotlibrc.template 2009-01-29 16:51:12 UTC (rev 6847) @@ -290,7 +290,11 @@ # A value of 20000 is probably a good # starting point. ### SAVING FIGURES -#path.simplify : False # When True, simplify paths in vector backends, such as PDF, PS and SVG +#path.simplify : False # When True, simplify paths in vector backends, such as + # PDF, PS and SVG +#path.simplify_threshold : 0.1 # The threshold of similarity below which + # vertices will be removed in the simplification + # process # the default savefig params can be different from the display params # Eg, you may want a higher resolution, or to make the figure Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/src/_backend_agg.cpp 2009-01-29 16:51:12 UTC (rev 6847) @@ -267,11 +267,11 @@ Py::Callable method(method_obj); Py::Object py_snap = method.apply(Py::Tuple()); if (py_snap.isNone()) { - snap = SNAP_AUTO; + quantize_mode = QUANTIZE_AUTO; } else if (py_snap.isTrue()) { - snap = SNAP_TRUE; + quantize_mode = QUANTIZE_TRUE; } else { - snap = SNAP_FALSE; + quantize_mode = QUANTIZE_FALSE; } } @@ -366,55 +366,6 @@ return face; } -template<class Path> -bool should_snap(GCAgg& gc, Path& path, const agg::trans_affine& trans) { - // If this contains only straight horizontal or vertical lines, it should be - // quantized to the nearest pixels - double x0, y0, x1, y1; - unsigned code; - - switch (gc.snap) { - case GCAgg::SNAP_AUTO: - if (path.total_vertices() > 15) - return false; - - code = path.vertex(&x0, &y0); - if (code == agg::path_cmd_stop) { - path.rewind(0); - return false; - } - trans.transform(&x0, &y0); - - while ((code = path.vertex(&x1, &y1)) != agg::path_cmd_stop) { - trans.transform(&x1, &y1); - - switch (code) { - case agg::path_cmd_curve3: - case agg::path_cmd_curve4: - path.rewind(0); - return false; - case agg::path_cmd_line_to: - if (!(fabs(x0 - x1) < 1e-4 || fabs(y0 - y1) < 1e-4)) { - path.rewind(0); - return false; - } - } - - x0 = x1; - y0 = y1; - } - - path.rewind(0); - gc.isaa = false; - return true; - case GCAgg::SNAP_FALSE: - return false; - case GCAgg::SNAP_TRUE: - return true; - } - return false; -} - Py::Object RendererAgg::copy_from_bbox(const Py::Tuple& args) { //copy region in bbox to buffer and return swig/agg buffer object @@ -509,8 +460,8 @@ Py::Object RendererAgg::draw_markers(const Py::Tuple& args) { typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef SimplifyPath<transformed_path_t> simplify_t; - typedef agg::conv_curve<simplify_t> curve_t; + typedef PathQuantizer<transformed_path_t> quantize_t; + typedef agg::conv_curve<quantize_t> curve_t; typedef agg::conv_stroke<curve_t> stroke_t; typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; @@ -534,15 +485,12 @@ trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); - PathIterator marker_path(marker_path_obj); - // The built-in markers look better if snapping is turned on, but - // unfortunately, it can cause really small things to disappear. - // Disabling for now to revisit at a later date. - // const bool marker_snap = true; - bool marker_snap = should_snap(gc, marker_path, marker_trans); + PathIterator marker_path(marker_path_obj); transformed_path_t marker_path_transformed(marker_path, marker_trans); - simplify_t marker_path_simplified(marker_path_transformed, marker_snap, false, width, height); - curve_t marker_path_curve(marker_path_simplified); + quantize_t marker_path_quantized(marker_path_transformed, + gc.quantize_mode, + marker_path.total_vertices()); + curve_t marker_path_curve(marker_path_quantized); PathIterator path(path_obj); transformed_path_t path_transformed(path, trans); @@ -900,8 +848,7 @@ // Create and transform the path typedef agg::conv_transform<PathIterator> hatch_path_trans_t; - typedef SimplifyPath<hatch_path_trans_t> hatch_path_simplify_t; - typedef agg::conv_curve<hatch_path_simplify_t> hatch_path_curve_t; + typedef agg::conv_curve<hatch_path_trans_t> hatch_path_curve_t; typedef agg::conv_stroke<hatch_path_curve_t> hatch_path_stroke_t; PathIterator hatch_path(gc.hatchpath); @@ -910,8 +857,7 @@ hatch_trans *= agg::trans_affine_translation(0.0, 1.0); hatch_trans *= agg::trans_affine_scaling(HATCH_SIZE, HATCH_SIZE); hatch_path_trans_t hatch_path_trans(hatch_path, hatch_trans); - hatch_path_simplify_t hatch_path_simplify(hatch_path_trans, false, false, HATCH_SIZE, HATCH_SIZE); - hatch_path_curve_t hatch_path_curve(hatch_path_simplify); + hatch_path_curve_t hatch_path_curve(hatch_path_trans); hatch_path_stroke_t hatch_path_stroke(hatch_path_curve); hatch_path_stroke.width(1.0); hatch_path_stroke.line_cap(agg::square_cap); @@ -1005,9 +951,12 @@ Py::Object RendererAgg::draw_path(const Py::Tuple& args) { - typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef SimplifyPath<transformed_path_t> simplify_t; - typedef agg::conv_curve<simplify_t> curve_t; + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef PathNanRemover<transformed_path_t> nan_removed_t; + typedef PathClipper<nan_removed_t> clipped_t; + typedef PathQuantizer<clipped_t> quantized_t; + typedef PathSimplifier<quantized_t> simplify_t; + typedef agg::conv_curve<simplify_t> curve_t; _VERBOSE("RendererAgg::draw_path"); args.verify_length(3, 4); @@ -1030,12 +979,15 @@ trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); - bool snap = should_snap(gc, path, trans); + bool clip = !face.first; bool simplify = path.should_simplify() && !face.first; transformed_path_t tpath(path, trans); - simplify_t simplified(tpath, snap, simplify, width, height); - curve_t curve(simplified); + nan_removed_t nan_removed(tpath, true, path.has_curves()); + clipped_t clipped(nan_removed, clip, width, height); + quantized_t quantized(clipped, gc.quantize_mode, path.total_vertices()); + simplify_t simplified(quantized, simplify, path.simplify_threshold()); + curve_t curve(simplified); try { _draw_path(curve, has_clippath, face, gc); @@ -1063,9 +1015,11 @@ const Py::SeqBase<Py::Object>& linestyles_obj, const Py::SeqBase<Py::Int>& antialiaseds) { typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t; - typedef SimplifyPath<transformed_path_t> simplify_t; - typedef agg::conv_curve<simplify_t> simplified_curve_t; - typedef agg::conv_curve<transformed_path_t> curve_t; + typedef PathNanRemover<transformed_path_t> nan_removed_t; + typedef PathClipper<nan_removed_t> clipped_t; + typedef PathQuantizer<clipped_t> quantized_t; + typedef agg::conv_curve<quantized_t> quantized_curve_t; + typedef agg::conv_curve<clipped_t> curve_t; GCAgg gc(dpi); @@ -1144,7 +1098,6 @@ facepair_t face; face.first = Nfacecolors != 0; agg::trans_affine trans; - bool snap = false; for (i = 0; i < N; ++i) { typename PathGenerator::path_iterator path = path_generator(i); @@ -1192,26 +1145,29 @@ } if (check_snap) { - snap = should_snap(gc, path, trans); gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); transformed_path_t tpath(path, trans); - simplify_t simplified(tpath, snap, false, width, height); + nan_removed_t nan_removed(tpath, true, has_curves); + clipped_t clipped(nan_removed, !face.first, width, height); + quantized_t quantized(clipped, gc.quantize_mode, path.total_vertices()); if (has_curves) { - simplified_curve_t curve(simplified); + quantized_curve_t curve(quantized); _draw_path(curve, has_clippath, face, gc); } else { - _draw_path(simplified, has_clippath, face, gc); + _draw_path(quantized, has_clippath, face, gc); } } else { gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); transformed_path_t tpath(path, trans); + nan_removed_t nan_removed(tpath, true, has_curves); + clipped_t clipped(nan_removed, !face.first, width, height); if (has_curves) { - curve_t curve(tpath); + curve_t curve(clipped); _draw_path(curve, has_clippath, face, gc); } else { - _draw_path(tpath, has_clippath, face, gc); + _draw_path(clipped, has_clippath, face, gc); } } } Modified: trunk/matplotlib/src/_backend_agg.h =================================================================== --- trunk/matplotlib/src/_backend_agg.h 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/src/_backend_agg.h 2009-01-29 16:51:12 UTC (rev 6847) @@ -39,6 +39,7 @@ #include "agg_vcgen_markers_term.h" #include "agg_py_path_iterator.h" +#include "path_converters.h" // These are copied directly from path.py, and must be kept in sync #define STOP 0 @@ -121,13 +122,8 @@ typedef std::vector<std::pair<double, double> > dash_t; double dashOffset; dash_t dashes; + e_quantize_mode quantize_mode; - enum { - SNAP_AUTO, - SNAP_FALSE, - SNAP_TRUE - } snap; - Py::Object hatchpath; protected: Modified: trunk/matplotlib/src/_macosx.m =================================================================== --- trunk/matplotlib/src/_macosx.m 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/src/_macosx.m 2009-01-29 16:51:12 UTC (rev 6847) @@ -1,4 +1,4 @@ -#include <Cocoa/Cocoa.h> +#include <Cocoa/Cocoa.h> #include <ApplicationServices/ApplicationServices.h> #include <sys/socket.h> #include <Python.h> @@ -23,7 +23,7 @@ * [ a b 0] * [ c d 0] * [ tx ty 1] - */ + */ typedef struct { double a; @@ -47,7 +47,7 @@ #define LINETO 2 #define CURVE3 3 #define CURVE4 4 -#define CLOSEPOLY 5 +#define CLOSEPOLY 0x4f /* Hatching */ #define HATCH_SIZE 72 @@ -132,7 +132,7 @@ sigint_socket = CFSocketCreateWithNative(kCFAllocatorDefault, channel[0], - kCFSocketReadCallBack, + kCFSocketReadCallBack, _callback, NULL); if (sigint_socket) @@ -470,8 +470,8 @@ } else { - CGContextSetLineWidth(cr, 1.0); - CGContextSetLineCap(cr, kCGLineCapSquare); + CGContextSetLineWidth(cr, 1.0); + CGContextSetLineCap(cr, kCGLineCapSquare); CGContextDrawPath(cr, kCGPathFillStroke); } } @@ -608,7 +608,7 @@ static PyObject* GraphicsContext_set_alpha (GraphicsContext* self, PyObject* args) -{ +{ float alpha; if (!PyArg_ParseTuple(args, "f", &alpha)) return NULL; CGContextRef cr = self->cr; @@ -624,8 +624,8 @@ static PyObject* GraphicsContext_set_antialiased (GraphicsContext* self, PyObject* args) -{ - int shouldAntialias; +{ + int shouldAntialias; if (!PyArg_ParseTuple(args, "i", &shouldAntialias)) return NULL; CGContextRef cr = self->cr; if (!cr) @@ -640,7 +640,7 @@ static PyObject* GraphicsContext_set_capstyle (GraphicsContext* self, PyObject* args) -{ +{ char* string; CGLineCap cap; @@ -662,7 +662,7 @@ return NULL; } CGContextSetLineCap(cr, cap); - + Py_INCREF(Py_None); return Py_None; } @@ -964,7 +964,7 @@ static PyObject* GraphicsContext_set_dashes (GraphicsContext* self, PyObject* args) -{ +{ PyObject* offset; PyObject* dashes; @@ -1026,7 +1026,7 @@ static PyObject* GraphicsContext_set_linewidth (GraphicsContext* self, PyObject* args) -{ +{ float width; if (!PyArg_ParseTuple(args, "f", &width)) return NULL; @@ -1067,7 +1067,7 @@ return NULL; } CGContextSetLineJoin(cr, join); - + Py_INCREF(Py_None); return Py_None; } @@ -1128,7 +1128,7 @@ PyObject* rgbFace; int ok; - + CGContextRef cr = self->cr; if (!cr) @@ -1150,7 +1150,7 @@ int n = _draw_path(cr, path, affine); if (n==-1) return NULL; - + if (n > 0) { PyObject* hatchpath; @@ -1235,7 +1235,7 @@ int ok; float r, g, b; double x, y; - + CGContextRef cr = self->cr; if (!cr) @@ -1322,7 +1322,7 @@ } static BOOL _clip(CGContextRef cr, PyObject* object) -{ +{ if (object == Py_None) return true; PyArrayObject* array = NULL; @@ -1362,8 +1362,8 @@ static PyObject* GraphicsContext_draw_path_collection (GraphicsContext* self, PyObject* args) { - PyObject* master_transform_obj; - PyObject* cliprect; + PyObject* master_transform_obj; + PyObject* cliprect; PyObject* clippath; PyObject* clippath_transform; PyObject* paths; @@ -1538,10 +1538,10 @@ if (Nlinewidths==1) { double linewidth = PyFloat_AsDouble(PySequence_ITEM(linewidths, 0)); - CGContextSetLineWidth(cr, (CGFloat)linewidth); + CGContextSetLineWidth(cr, (CGFloat)linewidth); } else if (Nlinewidths==0) - CGContextSetLineWidth(cr, 0.0); + CGContextSetLineWidth(cr, 0.0); if (Nlinestyles==1) { @@ -1613,7 +1613,7 @@ if (Nlinewidths > 1) { double linewidth = PyFloat_AsDouble(PySequence_ITEM(linewidths, i % Nlinewidths)); - CGContextSetLineWidth(cr, (CGFloat)linewidth); + CGContextSetLineWidth(cr, (CGFloat)linewidth); } if (Nlinestyles > 1) @@ -2057,15 +2057,15 @@ {"Chicago", /* 22 */ "", "", - ""}, + ""}, {"Charcoal", /* 23 */ "", "", - ""}, + ""}, {"Impact", /* 24 */ "", "", - ""}, + ""}, {"Playbill", /* 25 */ "", "", @@ -2073,7 +2073,7 @@ {"AndaleMono", /* 26 */ "", "", - ""}, + ""}, {"BitstreamVeraSansMono-Roman", /* 27 */ "BitstreamVeraSansMono-Bold", "BitstreamVeraSansMono-Oblique", @@ -2091,7 +2091,7 @@ "CourierNewPS-ItalicMT", "CourierNewPS-Bold-ItalicMT"}, }; - + if(!PyList_Check(family)) return 0; n = PyList_GET_SIZE(family); @@ -2106,7 +2106,7 @@ break; } } - /* If the font name is not found in mapping, we assume */ + /* If the font name is not found in mapping, we assume */ /* that the user specified the Postscript name directly */ /* Check if this font can be found on the system */ @@ -2135,7 +2135,7 @@ static PyObject* GraphicsContext_draw_text (GraphicsContext* self, PyObject* args) -{ +{ float x; float y; const UniChar* text; @@ -2335,7 +2335,7 @@ static PyObject* GraphicsContext_get_text_width_height_descent(GraphicsContext* self, PyObject* args) -{ +{ const UniChar* text; int n; PyObject* family; @@ -2449,7 +2449,7 @@ if(!PyArg_ParseTuple(args, "ffiiOOOO", &x, &y, - &nrows, + &nrows, &ncols, &image, &cliprect, @@ -2661,7 +2661,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - GraphicsContext_methods, /* tp_methods */ + GraphicsContext_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -2695,7 +2695,7 @@ int height; if(!self->view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return -1; } @@ -2736,7 +2736,7 @@ View* view = self->view; if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } [view setNeedsDisplay: YES]; @@ -2752,7 +2752,7 @@ NSRect rubberband; if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } if(!PyArg_ParseTuple(args, "iiii", &x0, &y0, &x1, &y1)) return NULL; @@ -2787,7 +2787,7 @@ View* view = self->view; if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } [view removeRubberband]; @@ -2845,7 +2845,7 @@ if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } if(!PyArg_ParseTuple(args, "u#ff", @@ -2891,7 +2891,7 @@ else if ([extension isEqualToString: @"png"]) filetype = NSPNGFileType; else - { PyErr_SetString(PyExc_ValueError, "Unknown file type"); + { PyErr_SetString(PyExc_ValueError, "Unknown file type"); return NULL; } @@ -2914,7 +2914,7 @@ if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } if(!PyArg_ParseTuple(args, "u#", &characters, &n)) return NULL; @@ -2960,7 +2960,7 @@ context.info = &interrupted; sigint_socket = CFSocketCreateWithNative(kCFAllocatorDefault, channel[0], - kCFSocketReadCallBack, + kCFSocketReadCallBack, _callback, &context); if (sigint_socket) @@ -3100,7 +3100,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - FigureCanvas_methods, /* tp_methods */ + FigureCanvas_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -3147,7 +3147,7 @@ if(!self->window) { - PyErr_SetString(PyExc_RuntimeError, "NSWindow* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSWindow* is NULL"); return -1; } @@ -3157,7 +3157,7 @@ view = canvas->view; if (!view) /* Something really weird going on */ { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return -1; } @@ -3276,7 +3276,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - FigureManager_methods, /* tp_methods */ + FigureManager_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -3471,7 +3471,7 @@ view = canvas->view; if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return -1; } @@ -3748,7 +3748,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - NavigationToolbar_methods, /* tp_methods */ + NavigationToolbar_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -3902,7 +3902,7 @@ view = ((FigureCanvas*)canvas)->view; if (!view) /* Something really weird going on */ { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); PyErr_Print(); Py_DECREF(canvas); Py_DECREF(master); @@ -4003,7 +4003,7 @@ view = canvas->view; if(!view) { - PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); + PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return -1; } @@ -4173,7 +4173,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - NavigationToolbar2_methods, /* tp_methods */ + NavigationToolbar2_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ Modified: trunk/matplotlib/src/_path.cpp =================================================================== --- trunk/matplotlib/src/_path.cpp 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/src/_path.cpp 2009-01-29 16:51:12 UTC (rev 6847) @@ -1,5 +1,6 @@ #include "agg_py_path_iterator.h" #include "agg_py_transforms.h" +#include "path_converters.h" #include <limits> #include <math.h> @@ -53,6 +54,8 @@ "path_intersects_path(p1, p2)"); add_varargs_method("convert_path_to_polygons", &_path_module::convert_path_to_polygons, "convert_path_to_polygons(path, trans, width, height)"); + add_varargs_method("cleanup_path", &_path_module::cleanup_path, + "cleanup_path(path, trans, remove_nans, clip, quantize, simplify, curves)"); initialize("Helper functions for paths"); } @@ -72,6 +75,7 @@ Py::Object count_bboxes_overlapping_bbox(const Py::Tuple& args); Py::Object path_intersects_path(const Py::Tuple& args); Py::Object convert_path_to_polygons(const Py::Tuple& args); + Py::Object cleanup_path(const Py::Tuple& args); }; // @@ -1105,17 +1109,21 @@ PathIterator p1(args[0]); PathIterator p2(args[1]); bool filled = false; - if (args.size() == 3) { - filled = args[2].isTrue(); + if (args.size() == 3) + { + filled = args[2].isTrue(); } - if (!filled) { - return Py::Int(::path_intersects_path(p1, p2)); - } else { - return Py::Int(::path_intersects_path(p1, p2) - || ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine()) - || ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine())); + if (!filled) + { + return Py::Int(::path_intersects_path(p1, p2)); } + else + { + return Py::Int(::path_intersects_path(p1, p2) + || ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine()) + || ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine())); + } } void _add_polygon(Py::List& polygons, const std::vector<double>& polygon) { @@ -1134,9 +1142,11 @@ Py::Object _path_module::convert_path_to_polygons(const Py::Tuple& args) { - typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef SimplifyPath<transformed_path_t> simplify_t; - typedef agg::conv_curve<simplify_t> curve_t; + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef PathNanRemover<transformed_path_t> nan_removal_t; + typedef PathClipper<nan_removal_t> clipped_t; + typedef PathSimplifier<clipped_t> simplify_t; + typedef agg::conv_curve<simplify_t> curve_t; typedef std::vector<double> vertices_t; @@ -1147,11 +1157,15 @@ double width = Py::Float(args[2]); double height = Py::Float(args[3]); - bool simplify = path.should_simplify() && width != 0.0 && height != 0.0; + bool do_clip = width != 0.0 && height != 0.0; + bool simplify = path.should_simplify(); + transformed_path_t tpath(path, trans); - simplify_t simplified(tpath, false, simplify, width, height); - curve_t curve(simplified); + nan_removal_t nan_removed(tpath, true, path.has_curves()); + clipped_t clipped(nan_removed, do_clip, width, height); + simplify_t simplified(clipped, simplify, path.simplify_threshold()); + curve_t curve(simplified); Py::List polygons; vertices_t polygon; @@ -1162,7 +1176,8 @@ while ((code = curve.vertex(&x, &y)) != agg::path_cmd_stop) { - if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { + if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) + { if (polygon.size() >= 2) { polygon.push_back(polygon[0]); @@ -1170,8 +1185,11 @@ _add_polygon(polygons, polygon); } polygon.clear(); - } else { - if (code == agg::path_cmd_move_to) { + } + else + { + if (code == agg::path_cmd_move_to) + { _add_polygon(polygons, polygon); polygon.clear(); } @@ -1185,6 +1203,152 @@ return polygons; } +template<class VertexSource> +void __cleanup_path(VertexSource& source, + std::vector<double>& vertices, + std::vector<uint8_t>& codes) { + unsigned code; + double x, y; + do + { + code = source.vertex(&x, &y); + vertices.push_back(x); + vertices.push_back(y); + codes.push_back((uint8_t)code); + } while (code != agg::path_cmd_stop); +} + +void _cleanup_path(PathIterator& path, const agg::trans_affine& trans, + bool remove_nans, bool do_clip, + const agg::rect_base<double>& rect, + e_quantize_mode quantize_mode, bool do_simplify, + bool return_curves, std::vector<double>& vertices, + std::vector<uint8_t>& codes) { + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef PathNanRemover<transformed_path_t> nan_removal_t; + typedef PathClipper<nan_removal_t> clipped_t; + typedef PathQuantizer<clipped_t> quantized_t; + typedef PathSimplifier<quantized_t> simplify_t; + typedef agg::conv_curve<simplify_t> curve_t; + + transformed_path_t tpath(path, trans); + nan_removal_t nan_removed(tpath, remove_nans, path.has_curves()); + clipped_t clipped(nan_removed, do_clip, rect); + quantized_t quantized(clipped, quantize_mode, path.total_vertices()); + simplify_t simplified(quantized, do_simplify, path.simplify_threshold()); + + vertices.reserve(path.total_vertices() * 2); + codes.reserve(path.total_vertices()); + + if (return_curves) + { + __cleanup_path(simplified, vertices, codes); + } + else + { + curve_t curve(simplified); + __cleanup_path(curve, vertices, codes); + } +} + +Py::Object _path_module::cleanup_path(const Py::Tuple& args) +{ + args.verify_length(7); + + PathIterator path(args[0]); + agg::trans_affine trans = py_to_agg_transformation_matrix(args[1], false); + bool remove_nans = args[2].isTrue(); + + Py::Object clip_obj = args[3]; + bool do_clip; + agg::rect_base<double> clip_rect; + if (clip_obj.isNone()) + { + do_clip = false; + } + else + { + double x1, y1, x2, y2; + Py::Tuple clip_tuple(clip_obj); + x1 = Py::Float(clip_tuple[0]); + y1 = Py::Float(clip_tuple[1]); + x2 = Py::Float(clip_tuple[2]); + y2 = Py::Float(clip_tuple[3]); + clip_rect.init(x1, y1, x2, y2); + do_clip = true; + } + + Py::Object quantize_obj = args[4]; + e_quantize_mode quantize_mode; + if (quantize_obj.isNone()) + { + quantize_mode = QUANTIZE_AUTO; + } + else if (quantize_obj.isTrue()) + { + quantize_mode = QUANTIZE_TRUE; + } + else + { + quantize_mode = QUANTIZE_FALSE; + } + + bool simplify; + Py::Object simplify_obj = args[5]; + if (simplify_obj.isNone()) + { + simplify = path.should_simplify(); + } + else + { + simplify = simplify_obj.isTrue(); + } + + bool return_curves = args[6].isTrue(); + + std::vector<double> vertices; + std::vector<uint8_t> codes; + + _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, quantize_mode, + simplify, return_curves, vertices, codes); + + npy_intp length = codes.size(); + npy_intp dims[] = { length, 2, 0 }; + + PyArrayObject* vertices_obj = NULL; + PyArrayObject* codes_obj = NULL; + Py::Tuple result(2); + try { + vertices_obj = (PyArrayObject*)PyArray_SimpleNew + (2, dims, PyArray_DOUBLE); + if (vertices_obj == NULL) + { + throw Py::MemoryError("Could not allocate result array"); + } + + codes_obj = (PyArrayObject*)PyArray_SimpleNew + (1, dims, PyArray_UINT8); + if (codes_obj == NULL) + { + throw Py::MemoryError("Could not allocate result array"); + } + + memcpy(PyArray_DATA(vertices_obj), &vertices[0], sizeof(double) * 2 * length); + memcpy(PyArray_DATA(codes_obj), &codes[0], sizeof(uint8_t) * length); + + result[0] = Py::Object((PyObject*)vertices_obj, true); + result[1] = Py::Object((PyObject*)codes_obj, true); + } + catch (...) + { + Py_XDECREF(vertices_obj); + Py_XDECREF(codes_obj); + throw; + } + + return result; +} + extern "C" DL_EXPORT(void) init_path(void) Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-29 16:16:14 UTC (rev 6846) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-29 16:51:12 UTC (rev 6847) @@ -5,28 +5,48 @@ #define PY_ARRAY_TYPES_PREFIX NumPy #include "numpy/arrayobject.h" #include "agg_path_storage.h" -#include "MPL_isnan.h" -#include "mplutils.h" -#include <queue> +/* + This file contains a vertex source to adapt Python Numpy arrays to + Agg paths. It works as an iterator, and converts on-the-fly without + the need for a full copy of the data. + */ + +/************************************************************ + PathIterator acts as a bridge between Numpy and Agg. Given a pair of + Numpy arrays, vertices and codes, it iterates over those vertices and + codes, using the standard Agg vertex source interface: + + unsigned vertex(double* x, double* y) + */ class PathIterator { + /* We hold references to the Python objects, not just the + underlying data arrays, so that Python reference counting can + work. + */ PyArrayObject* m_vertices; PyArrayObject* m_codes; + size_t m_iterator; size_t m_total_vertices; - size_t m_ok; + + /* This class doesn't actually do any simplification, but we + store the value here, since it is obtained from the Python object. + */ bool m_should_simplify; - static const unsigned char num_extra_points_map[16]; - static const unsigned code_map[]; + double m_simplify_threshold; public: + /* path_obj is an instance of the class Path as defined in path.py */ PathIterator(const Py::Object& path_obj) : - m_vertices(NULL), m_codes(NULL), m_iterator(0), m_should_simplify(false) + m_vertices(NULL), m_codes(NULL), m_iterator(0), m_should_simplify(false), + m_simplify_threshold(1.0 / 9.0) { - Py::Object vertices_obj = path_obj.getAttr("vertices"); - Py::Object codes_obj = path_obj.getAttr("codes"); - Py::Object should_simplify_obj = path_obj.getAttr("should_simplify"); + Py::Object vertices_obj = path_obj.getAttr("vertices"); + Py::Object codes_obj = path_obj.getAttr("codes"); + Py::Object should_simplify_obj = path_obj.getAttr("should_simplify"); + Py::Object simplify_threshold_obj = path_obj.getAttr("simplify_threshold"); m_vertices = (PyArrayObject*)PyArray_FromObject (vertices_obj.ptr(), PyArray_DOUBLE, 2, 2); @@ -44,11 +64,11 @@ throw Py::ValueError("Invalid codes array."); if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0)) throw Py::ValueError("Codes array is wrong length"); - m_ok = 0; } - m_should_simplify = should_simplify_obj.isTrue(); - m_total_vertices = m_vertices->dimensions[0]; + m_should_simplify = should_simplify_obj.isTrue(); + m_total_vertices = PyArray_DIM(m_vertices, 0); + m_simplify_threshold = Py::Float(simplify_threshold_obj); } ~PathIterator() @@ -57,20 +77,19 @@ Py_XDECREF(m_codes); } -private: - inline void vertex(const unsigned idx, double* x, double* y) + inline unsigned vertex(double* x, double* y) { + if (m_iterator >= m_total_vertices) return agg::path_cmd_stop; + + const size_t idx = m_iterator++; + char* pair = (char*)PyArray_GETPTR2(m_vertices, idx, 0); *x = *(double*)pair; *y = *(double*)(pair + PyArray_STRIDE(m_vertices, 1)); - } - inline unsigned vertex_with_code(const unsigned idx, double* x, double* y) - { - vertex(idx, x, y); if (m_codes) { - return code_map[(int)*(char *)PyArray_GETPTR1(m_codes, idx)]; + return (unsigned)(*(char *)PyArray_GETPTR1(m_codes, idx)); } else { @@ -78,97 +97,6 @@ } } -public: - inline unsigned vertex(double* x, double* y) - { - if (m_iterator >= m_total_vertices) return agg::path_cmd_stop; - unsigned code = vertex_with_code(m_iterator++, x, y); - - if (!m_codes) { - // This is the fast path for when we know we have no curves - if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) - { - do - { - if (m_iterator < m_total_vertices) - { - vertex(m_iterator++, x, y); - } - else - { - return agg::path_cmd_stop; - } - } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); - return agg::path_cmd_move_to; - } - } - else - { - // This is the slow method for when there might be curves. - - ... [truncated message content] |
From: <jr...@us...> - 2009-01-29 17:57:50
|
Revision: 6849 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6849&view=rev Author: jrevans Date: 2009-01-29 17:57:43 +0000 (Thu, 29 Jan 2009) Log Message: ----------- hanged the order of arguments for unit.ConverterInterface class. Modified Paths: -------------- trunk/matplotlib/examples/units/basic_units.py trunk/matplotlib/lib/matplotlib/axis.py trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/lib/matplotlib/units.py Modified: trunk/matplotlib/examples/units/basic_units.py =================================================================== --- trunk/matplotlib/examples/units/basic_units.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/examples/units/basic_units.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -98,6 +98,9 @@ '__sub__':ConvertAllProxy, '__mul__':ConvertAllProxy, '__rmul__':ConvertAllProxy, + '__cmp__':ConvertAllProxy, + '__lt__':ConvertAllProxy, + '__gt__':ConvertAllProxy, '__len__':PassThroughProxy} def __new__(cls, value, unit): @@ -228,7 +231,7 @@ return self.conversions[unit] def convert_value_to(self, value, unit): - #print 'convert value to: value ="%s", unit="%s"'%(value, type(unit)), self.conversions + #print 'convert value to: value ="%s", unit="%s"'%(value, type(unit)), self.conversions conversion_fn = self.conversions[unit] ret = conversion_fn(value) return ret Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/axis.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -939,7 +939,7 @@ converter = munits.registry.get_converter(data) if converter is None: return False self.converter = converter - default = self.converter.default_units(self, data) + default = self.converter.default_units(data, self) #print 'update units: default="%s", units=%s"'%(default, self.units) if default is not None and self.units is None: self.set_units(default) @@ -955,7 +955,7 @@ if self.converter is None: return - info = self.converter.axisinfo(self, self.units) + info = self.converter.axisinfo(self.units, self) if info is None: return if info.majloc is not None and self.major.locator!=info.majloc: @@ -982,7 +982,7 @@ #print 'convert_units returning identity: units=%s, converter=%s'%(self.units, self.converter) return x - ret = self.converter.convert(self, x, self.units) + ret = self.converter.convert(x, self.units, self) #print 'convert_units converting: axis=%s, units=%s, converter=%s, in=%s, out=%s'%(self, self.units, self.converter, x, ret) return ret Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/dates.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -1007,51 +1007,52 @@ """The units are equivalent to the timezone.""" @staticmethod - def axisinfo(axis, unit): + def axisinfo(unit, axis): 'return the unit AxisInfo' # make sure that the axis does not start at 0 - ax = axis.axes + if axis: + ax = axis.axes - if axis is ax.get_xaxis(): - xmin, xmax = ax.dataLim.intervalx - if xmin==0.: - # no data has been added - let's set the default datalim. - # We should probably use a better proxy for the datalim - # have been updated than the ignore setting - dmax = today = datetime.date.today() - dmin = today-datetime.timedelta(days=10) + if axis is ax.get_xaxis(): + xmin, xmax = ax.dataLim.intervalx + if xmin==0.: + # no data has been added - let's set the default datalim. + # We should probably use a better proxy for the datalim + # have been updated than the ignore setting + dmax = today = datetime.date.today() + dmin = today-datetime.timedelta(days=10) - ax._process_unit_info(xdata=(dmin, dmax)) - dmin, dmax = ax.convert_xunits([dmin, dmax]) + ax._process_unit_info(xdata=(dmin, dmax)) + dmin, dmax = ax.convert_xunits([dmin, dmax]) - ax.viewLim.intervalx = dmin, dmax - ax.dataLim.intervalx = dmin, dmax - elif axis is ax.get_yaxis(): - ymin, ymax = ax.dataLim.intervaly - if ymin==0.: - # no data has been added - let's set the default datalim. - # We should probably use a better proxy for the datalim - # have been updated than the ignore setting - dmax = today = datetime.date.today() - dmin = today-datetime.timedelta(days=10) + ax.viewLim.intervalx = dmin, dmax + ax.dataLim.intervalx = dmin, dmax + elif axis is ax.get_yaxis(): + ymin, ymax = ax.dataLim.intervaly + if ymin==0.: + # no data has been added - let's set the default datalim. + # We should probably use a better proxy for the datalim + # have been updated than the ignore setting + dmax = today = datetime.date.today() + dmin = today-datetime.timedelta(days=10) - ax._process_unit_info(ydata=(dmin, dmax)) - dmin, dmax = ax.convert_yunits([dmin, dmax]) + ax._process_unit_info(ydata=(dmin, dmax)) + dmin, dmax = ax.convert_yunits([dmin, dmax]) - ax.viewLim.intervaly = dmin, dmax - ax.dataLim.intervaly = dmin, dmax + ax.viewLim.intervaly = dmin, dmax + ax.dataLim.intervaly = dmin, dmax majloc = AutoDateLocator(tz=unit) majfmt = AutoDateFormatter(majloc, tz=unit) return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='' ) @staticmethod - def convert(axis, value, unit): + def convert(value, unit, axis): if units.ConversionInterface.is_numlike(value): return value return date2num(value) @staticmethod - def default_units(axis, x): + def default_units(x, axis): 'Return the default unit for *x* or None' return None Modified: trunk/matplotlib/lib/matplotlib/units.py =================================================================== --- trunk/matplotlib/lib/matplotlib/units.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/units.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -69,17 +69,17 @@ sequences) and convert them to values mpl can use """ @staticmethod - def axisinfo(axis, unit): + def axisinfo(unit, axis): 'return an units.AxisInfo instance for axis with the specified units' return None @staticmethod - def default_units(axis, x): + def default_units(x, axis): 'return the default unit for x or None for the given axis' return None @staticmethod - def convert(axis, obj, unit): + def convert(obj, unit, axis): """ convert obj using unit for the specified axis. If obj is a sequence, return the converted sequence. The ouput must be a sequence of scalars This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-01-29 18:13:01
|
Revision: 6851 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6851&view=rev Author: jdh2358 Date: 2009-01-29 18:12:56 +0000 (Thu, 29 Jan 2009) Log Message: ----------- Merged revisions 6850 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6850 | jdh2358 | 2009-01-29 10:11:07 -0800 (Thu, 29 Jan 2009) | 1 line applied Sandro's doc patch ........ Modified Paths: -------------- trunk/matplotlib/doc/devel/coding_guide.rst trunk/matplotlib/doc/devel/documenting_mpl.rst trunk/matplotlib/doc/faq/howto_faq.rst Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6841 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6850 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850 Modified: trunk/matplotlib/doc/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/doc/devel/coding_guide.rst 2009-01-29 18:11:07 UTC (rev 6850) +++ trunk/matplotlib/doc/devel/coding_guide.rst 2009-01-29 18:12:56 UTC (rev 6851) @@ -44,7 +44,7 @@ * if your changes are non-trivial, please make an entry in the :file:`CHANGELOG` -* if you change the API, please document it in :file:`API_CHANGES`, +* if you change the API, please document it in :file:`doc/api/api_changes.rst`, and consider posting to `matplotlib-devel <http://lists.sourceforge.net/mailman/listinfo/matplotlib-devel>`_ Modified: trunk/matplotlib/doc/devel/documenting_mpl.rst =================================================================== --- trunk/matplotlib/doc/devel/documenting_mpl.rst 2009-01-29 18:11:07 UTC (rev 6850) +++ trunk/matplotlib/doc/devel/documenting_mpl.rst 2009-01-29 18:12:56 UTC (rev 6851) @@ -252,7 +252,7 @@ taken, these figures can be included in the usual way:: .. plot:: pyplots/tex_unicode_demo.py - :include-source + :include-source: Examples -------- Modified: trunk/matplotlib/doc/faq/howto_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/howto_faq.rst 2009-01-29 18:11:07 UTC (rev 6850) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2009-01-29 18:12:56 UTC (rev 6851) @@ -137,7 +137,7 @@ used to calculate the text size, is not known until the figure is drawn (:meth:`matplotlib.figure.Figure.draw`). After the window is drawn and the text instance knows its renderer, you can call -:meth:`matplotlib.text.Text.get_window_extent``. One way to solve +:meth:`matplotlib.text.Text.get_window_extent`. One way to solve this chicken and egg problem is to wait until the figure is draw by connecting (:meth:`matplotlib.backend_bases.FigureCanvasBase.mpl_connect`) to the @@ -374,7 +374,7 @@ A frequent request is to have two scales for the left and right y-axis, which is possible using :func:`~matplotlib.pyplot.twinx` (more -than two scales are not currently supported, though it is on the wishq +than two scales are not currently supported, though it is on the wish list). This works pretty well, though there are some quirks when you are trying to interactively pan and zoom, since both scales do not get the signals. @@ -483,7 +483,7 @@ This is not what show does and unfortunately, because doing blocking calls across user interfaces can be tricky, is currently unsupported, -though we have made some pregress towards supporting blocking events. +though we have made some progress towards supporting blocking events. .. _howto-contribute: Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2009-01-29 22:45:48
|
Revision: 6855 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6855&view=rev Author: mdboom Date: 2009-01-29 21:44:10 +0000 (Thu, 29 Jan 2009) Log Message: ----------- Merged revisions 6854 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6854 | mdboom | 2009-01-29 16:36:54 -0500 (Thu, 29 Jan 2009) | 2 lines Document the 'resolution' kwarg to polar plots. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/projections/polar.py trunk/matplotlib/lib/matplotlib/pyplot.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6850 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6854 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-01-29 21:36:54 UTC (rev 6854) +++ trunk/matplotlib/CHANGELOG 2009-01-29 21:44:10 UTC (rev 6855) @@ -1,3 +1,6 @@ +2009-01-29 Document 'resolution' kwarg for polar plots. Support it + when using pyplot.polar, not just Figure.add_axes. - MGD + 2009-01-29 Rework the nan-handling/clipping/quantizing/simplification framework so each is an independent part of a pipeline. Expose the C++-implementation of all of this so it can be Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854 Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-01-29 21:36:54 UTC (rev 6854) +++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2009-01-29 21:44:10 UTC (rev 6855) @@ -182,10 +182,18 @@ def __init__(self, *args, **kwargs): """ Create a new Polar Axes for a polar plot. + + The following optional kwargs are supported: + + - *resolution*: The number of points of interpolation between + each pair of data points. Set to 1 to disable + interpolation. """ self._rpad = 0.05 - self.resolution = kwargs.pop('resolution', self.RESOLUTION) + self.resolution = kwargs.pop('resolution', None) + if self.resolution is None: + self.resolution = self.RESOLUTION Axes.__init__(self, *args, **kwargs) self.set_aspect('equal', adjustable='box', anchor='C') self.cla() Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2009-01-29 21:36:54 UTC (rev 6854) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009-01-29 21:44:10 UTC (rev 6855) @@ -1416,8 +1416,13 @@ Make a polar plot. Multiple *theta*, *r* arguments are supported, with format strings, as in :func:`~matplotlib.pyplot.plot`. + + An optional kwarg *resolution* sets the number of vertices to + interpolate between each pair of points. Set to 1 to disable + interpolation. """ - ax = gca(polar=True) + resolution = kwargs.pop('resolution', None) + ax = gca(polar=True, resolution=resolution) ret = ax.plot(*args, **kwargs) draw_if_interactive() return ret This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |