From: <jo...@us...> - 2008-09-07 10:57:18
|
Revision: 6072 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6072&view=rev Author: jouni Date: 2008-09-07 10:57:15 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/cbook.py Added Paths: ----------- trunk/matplotlib/examples/api/quad_bezier.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-06 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/CHANGELOG 2008-09-07 10:57:15 UTC (rev 6072) @@ -1,3 +1,6 @@ +2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF + and PS backends. Patch by Jae-Joon Lee. - JKS + 2008-09-06 Added 5-point star marker to plot command - EF 2008-09-05 Fix hatching in PS backend - MGD Added: trunk/matplotlib/examples/api/quad_bezier.py =================================================================== --- trunk/matplotlib/examples/api/quad_bezier.py (rev 0) +++ trunk/matplotlib/examples/api/quad_bezier.py 2008-09-07 10:57:15 UTC (rev 6072) @@ -0,0 +1,17 @@ +import numpy as np +import matplotlib.path as mpath +import matplotlib.patches as mpatches +import matplotlib.pyplot as plt + +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]), + fc="none", transform=ax.transData) + +ax.add_patch(pp1) +ax.plot([0.75], [0.25], "ro") +ax.set_title('The red point should be on the path') + +plt.draw() + Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008-09-06 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008-09-07 10:57:15 UTC (rev 6072) @@ -127,7 +127,8 @@ 'colorbar_only.py', 'color_cycle.py', 'donut_demo.py', - 'path_patch_demo.py' + 'path_patch_demo.py', + 'quad_bezier.py' ] units_dir = os.path.join('..', 'units') Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-09-06 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-09-07 10:57:15 UTC (rev 6072) @@ -26,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.backends.backend_mixed import MixedModeRenderer from matplotlib.cbook import Bunch, is_string_like, reverse_dict, \ - get_realpath_and_stat, is_writable_file_like, maxdict + get_realpath_and_stat, is_writable_file_like, maxdict, quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM @@ -1096,6 +1096,7 @@ tpath = transform.transform_path(path) cmds = [] + last_points = None for points, code in tpath.iter_segments(): if code == Path.MOVETO: cmds.extend(points) @@ -1104,15 +1105,15 @@ cmds.extend(points) cmds.append(Op.lineto) elif code == Path.CURVE3: - cmds.extend([points[0], points[1], - points[0], points[1], - points[2], points[3], - Op.curveto]) + points = quad2cubic(*(list(last_points[-2:]) + list(points))) + cmds.extend(points) + cmds.append(Op.curveto) elif code == Path.CURVE4: cmds.extend(points) cmds.append(Op.curveto) elif code == Path.CLOSEPOLY: cmds.append(Op.closepath) + last_points = points return cmds pathOperations = staticmethod(pathOperations) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-06 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-07 10:57:15 UTC (rev 6072) @@ -20,7 +20,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import is_string_like, get_realpath_and_stat, \ - is_writable_file_like, maxdict + is_writable_file_like, maxdict, quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font @@ -448,22 +448,23 @@ path = transform.transform_path(path) ps = [] + last_points = None for points, code in path.iter_segments(): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: ps.append("%g %g l" % tuple(points)) elif code == Path.CURVE3: + points = quad2cubic(*(list(last_points[-2:]) + list(points))) ps.append("%g %g %g %g %g %g c" % - (points[0], points[1], - points[0], points[1], - points[2], points[3])) + tuple(points[2:])) elif code == Path.CURVE4: ps.append("%g %g %g %g %g %g c" % tuple(points)) elif code == Path.CLOSEPOLY: ps.append("cl") + last_points = points + ps = "\n".join(ps) - return ps def _get_clip_path(self, clippath, clippath_transform): Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-09-06 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-09-07 10:57:15 UTC (rev 6072) @@ -1390,6 +1390,20 @@ """ return np.all(X[0] == X[-1]) +def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): + """ + Converts a quadratic Bezier curve to a cubic approximation. + + The inputs are the x and y coordinates of the three control points + of a quadratic curve, and the output is a tuple of x and y + coordinates of the four control points of the cubic curve. + """ + # c0x, c0y = q0x, q0y + c1x, c1y = q0x + 2./3. * (q1x - q0x), q0y + 2./3. * (q1y - q0y) + c2x, c2y = c1x + 1./3. * (q2x - q0x), c1y + 1./3. * (q2y - q0y) + # c3x, c3y = q2x, q2y + return q0x, q0y, c1x, c1y, c2x, c2y, q2x, q2y + # a dict to cross-map linestyle arguments _linestyles = [('-', 'solid'), ('--', 'dashed'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-09-07 11:28:47
|
Revision: 6074 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6074&view=rev Author: jouni Date: 2008-09-07 11:28:45 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Merged revisions 6073 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r6073 | jouni | 2008-09-07 14:19:13 +0300 (Sun, 07 Sep 2008) | 3 lines Changed full arrows slightly to avoid an xpdf rendering problem reported by Friedrich Hagedorn. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/patches.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6068 + /branches/v0_91_maint:1-6073 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-07 11:19:13 UTC (rev 6073) +++ trunk/matplotlib/CHANGELOG 2008-09-07 11:28:45 UTC (rev 6074) @@ -1,3 +1,6 @@ +2008-09-07 Changed full arrows slightly to avoid an xpdf rendering + problem reported by Friedrich Hagedorn. - JKS + 2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. - JKS Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008-09-07 11:19:13 UTC (rev 6073) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008-09-07 11:28:45 UTC (rev 6074) @@ -772,7 +772,11 @@ if shape == 'right': coords = right_half_arrow elif shape == 'full': - coords=np.concatenate([left_half_arrow,right_half_arrow[::-1]]) + # The half-arrows contain the midpoint of the stem, + # which we can omit from the full arrow. Including it + # twice caused a problem with xpdf. + coords=np.concatenate([left_half_arrow[:-1], + right_half_arrow[-2::-1]]) else: raise ValueError, "Got unknown shape: %s" % shape cx = float(dx)/distance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-09-10 12:33:38
|
Revision: 6078 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6078&view=rev Author: mdboom Date: 2008-09-10 12:33:33 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Add "filled" kwarg to path_intersects_path Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/_path.cpp Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-09 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/CHANGELOG 2008-09-10 12:33:33 UTC (rev 6078) @@ -1,7 +1,10 @@ +2008-09-10 Add "filled" kwarg to Path.intersects_path and + Path.intersects_bbox. - MGD + 2008-09-07 Changed full arrows slightly to avoid an xpdf rendering problem reported by Friedrich Hagedorn. - JKS -2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF +2008-09-07 Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. - JKS 2008-09-06 Added 5-point star marker to plot command - EF Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008-09-09 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/lib/matplotlib/path.py 2008-09-10 12:33:33 UTC (rev 6078) @@ -242,21 +242,29 @@ transform = transform.frozen() return Bbox(get_path_extents(self, transform)) - def intersects_path(self, other): + def intersects_path(self, other, filled=True): """ Returns *True* if this path intersects another given path. + + *filled*, when True, treats the paths as if they were filled. + That is, if one path completely encloses the other, + :meth:`intersects_path` will return True. """ - return path_intersects_path(self, other) + return path_intersects_path(self, other, filled) - def intersects_bbox(self, bbox): + def intersects_bbox(self, bbox, filled=True): """ Returns *True* if this path intersects a given :class:`~matplotlib.transforms.Bbox`. + + *filled*, when True, treats the path as if it was filled. + That is, if one path completely encloses the other, + :meth:`intersects_path` will return True. """ from transforms import BboxTransformTo rectangle = self.unit_rectangle().transformed( BboxTransformTo(bbox)) - result = self.intersects_path(rectangle) + result = self.intersects_path(rectangle, filled) return result def interpolated(self, steps): Modified: trunk/matplotlib/src/_path.cpp =================================================================== --- trunk/matplotlib/src/_path.cpp 2008-09-09 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/src/_path.cpp 2008-09-10 12:33:33 UTC (rev 6078) @@ -1081,14 +1081,22 @@ Py::Object _path_module::path_intersects_path(const Py::Tuple& args) { - args.verify_length(2); + args.verify_length(2, 3); PathIterator p1(args[0]); PathIterator p2(args[1]); + bool filled = false; + if (args.size() == 3) { + filled = args[2].isTrue(); + } - 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) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-09-10 18:46:13
|
Revision: 6080 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6080&view=rev Author: mdboom Date: 2008-09-10 18:46:10 +0000 (Wed, 10 Sep 2008) Log Message: ----------- [ 2089958 ] Path simplification for vector output backends Modified Paths: -------------- trunk/matplotlib/CHANGELOG 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/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 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/CHANGELOG 2008-09-10 18:46:10 UTC (rev 6080) @@ -1,3 +1,10 @@ +2008-09-10 [ 2089958 ] Path simplification for vector output backends + Leverage the simplification code exposed through + path_to_polygons to simplify certain well-behaved paths in + the vector backends (PDF, PS and SVG). "path.simplify" + must be set to True in matplotlibrc for this to work. - + MGD + 2008-09-10 Add "filled" kwarg to Path.intersects_path and Path.intersects_bbox. - MGD Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -331,6 +331,10 @@ def __init__(self, width, height, dpi, filename): self.width, self.height = width, height self.dpi = dpi + if rcParams['path.simplify']: + self.simplify = (width * dpi, height * dpi) + else: + self.simplify = None self.nextObject = 1 # next free object id self.xrefTable = [ [0, 65535, 'the zero object'] ] self.passed_in_file_object = False @@ -1092,12 +1096,12 @@ self.endStream() #@staticmethod - def pathOperations(path, transform): + def pathOperations(path, transform, simplify=None): tpath = transform.transform_path(path) cmds = [] last_points = None - for points, code in tpath.iter_segments(): + for points, code in tpath.iter_segments(simplify): if code == Path.MOVETO: cmds.extend(points) cmds.append(Op.moveto) @@ -1118,7 +1122,8 @@ pathOperations = staticmethod(pathOperations) def writePath(self, path, transform): - cmds = self.pathOperations(path, transform) + cmds = self.pathOperations( + path, transform, self.simplify) self.output(*cmds) def reserveObject(self, name=''): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -145,6 +145,10 @@ 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 @@ -444,12 +448,12 @@ # unflip im.flipud_out() - def _convert_path(self, path, transform): + def _convert_path(self, path, transform, simplify=None): path = transform.transform_path(path) ps = [] last_points = None - for points, code in path.iter_segments(): + for points, code in path.iter_segments(simplify): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: @@ -463,7 +467,7 @@ elif code == Path.CLOSEPOLY: ps.append("cl") last_points = points - + ps = "\n".join(ps) return ps @@ -482,7 +486,7 @@ """ Draws a Path instance using the given affine transform. """ - ps = self._convert_path(path, transform) + ps = self._convert_path(path, transform, self.simplify) self._draw_ps(ps, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -42,6 +42,10 @@ 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']: @@ -165,14 +169,14 @@ .scale(1.0, -1.0) .translate(0.0, self.height)) - def _convert_path(self, path, transform): + def _convert_path(self, path, transform, simplify=None): tpath = transform.transform_path(path) path_data = [] appender = path_data.append path_commands = self._path_commands currpos = 0 - for points, code in tpath.iter_segments(): + for points, code in tpath.iter_segments(simplify): if code == Path.CLOSEPOLY: segment = 'z' else: @@ -187,7 +191,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) + path_data = self._convert_path(path, trans_and_flip, self.simplify) self._draw_svg_element('path', 'd="%s"' % path_data, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -117,6 +117,9 @@ markersize = T.Float(6) antialiased = T.true + class path(TConfig): + simplify = T.false + class patch(TConfig): linewidth = T.Float(1.0) facecolor = T.Trait('blue', mplT.ColorHandler()) @@ -439,6 +442,8 @@ 'svg.image_noscale' : (self.tconfig.backend.svg, 'image_noscale'), 'svg.embed_char_paths' : (self.tconfig.backend.svg, 'embed_char_paths'), + # Path properties + 'path.simplify' : (self.tconfig.path, 'simplify') } def __setitem__(self, key, val): Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -476,6 +476,7 @@ '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' : [False, validate_bool] } if __name__ == '__main__': Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/path.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -145,12 +145,24 @@ def __len__(self): return len(self.vertices) - def iter_segments(self): + def iter_segments(self, simplify=None): """ 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: + + - No *codes* array + - No nonfinite values + - More than 128 vertices """ vertices = self.vertices if not len(vertices): @@ -166,7 +178,13 @@ CLOSEPOLY = self.CLOSEPOLY STOP = self.STOP - if codes is None: + 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: next_code = MOVETO for v in vertices: if (~isfinite(v)).any(): Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-09-10 18:46:10 UTC (rev 6080) @@ -487,6 +487,7 @@ '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' : [False, validate_bool] } if __name__ == '__main__': Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-09-10 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/matplotlibrc.template 2008-09-10 18:46:10 UTC (rev 6080) @@ -270,6 +270,8 @@ #contour.negative_linestyle : dashed # dashed | solid ### SAVING FIGURES +#path.simplify : False # When True, simplify paths in vector backends, such as PDF, PS and SVG + # the default savefig params can be different for the GUI backends. # Eg, you may want a higher resolution, or to make the figure # background white This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-09-11 20:24:51
|
Revision: 6085 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6085&view=rev Author: mdboom Date: 2008-09-11 20:24:49 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Fix backticks in PS output. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-11 19:30:39 UTC (rev 6084) +++ trunk/matplotlib/CHANGELOG 2008-09-11 20:24:49 UTC (rev 6085) @@ -1,3 +1,5 @@ +2008-09-11 Fix backtick in Postscript output. - MGD + 2008-09-10 [ 2089958 ] Path simplification for vector output backends Leverage the simplification code exposed through path_to_polygons to simplify certain well-behaved paths in Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-11 19:30:39 UTC (rev 6084) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-09-11 20:24:49 UTC (rev 6085) @@ -101,6 +101,7 @@ s=s.replace("(", "\\(") s=s.replace(")", "\\)") s=s.replace("'", "\\251") + s=s.replace("`", "\\301") s=re.sub(r"[^ -~\n]", lambda x: r"\%03o"%ord(x.group()), s) return s This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-09-13 14:28:15
|
Revision: 6089 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6089&view=rev Author: jdh2358 Date: 2008-09-13 14:28:09 +0000 (Sat, 13 Sep 2008) Log Message: ----------- replaced ipython run magic with code.InteractiveConsole.runsource Modified Paths: -------------- trunk/matplotlib/doc/sphinxext/plot_directive.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-09-12 21:21:16 UTC (rev 6088) +++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-09-13 14:28:09 UTC (rev 6089) @@ -13,7 +13,7 @@ source will be included inline, as well as a link to the source. """ -import sys, os, glob, shutil +import sys, os, glob, shutil, code from docutils.parsers.rst import directives try: @@ -26,11 +26,16 @@ import matplotlib -import IPython.Shell + matplotlib.use('Agg') import matplotlib.pyplot as plt -mplshell = IPython.Shell.MatplotlibShell('mpl') +#import IPython.Shell +#mplshell = IPython.Shell.MatplotlibShell('mpl') +console = code.InteractiveConsole() +def runfile(fname): + source = file(fname).read() + return console.runsource(source) options = {'alt': directives.unchanged, 'height': directives.length_or_unitless, @@ -58,7 +63,7 @@ def makefig(fullpath, outdir): """ - run a pyplot script and save the low and high res PNGs and a PDF in _static + run a pyplot script<t and save the low and high res PNGs and a PDF in _static """ fullpath = str(fullpath) # todo, why is unicode breaking this @@ -88,7 +93,8 @@ plt.close('all') # we need to clear between runs matplotlib.rcdefaults() - mplshell.magic_run(fullpath) + runfile(fullpath) + for format, dpi in formats: outname = os.path.join(outdir, '%s.%s' % (basename, format)) if os.path.exists(outname): continue Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008-09-12 21:21:16 UTC (rev 6088) +++ trunk/matplotlib/lib/matplotlib/text.py 2008-09-13 14:28:09 UTC (rev 6089) @@ -41,10 +41,11 @@ # these are not available for the object inspector until after the # class is build so we define an initial set here for the init # function and they will be overridden after object defn -artist.kwdocd['Text'] = """\ +artist.kwdocd['Text'] = """ ========================== ========================================================================= + Property Value + ========================== ========================================================================= alpha float - ========================== ========================================================================= animated [True | False] backgroundcolor any matplotlib color bbox rectangle prop dict plus key 'pad' which is a pad in points @@ -1003,7 +1004,7 @@ annotation to the point. Valid keys are ========= =========================================================== - Key Description + Key Description ========= =========================================================== width the width of the arrow in points frac the fraction of the arrow length occupied by the head @@ -1021,7 +1022,7 @@ coordinates of *xy* and *xytext*. ================= =================================================== - Property Description + Property Description ================= =================================================== 'figure points' points from the lower left corner of the figure 'figure pixels' pixels from the lower left corner of the figure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-09-18 06:09:12
|
Revision: 6106 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6106&view=rev Author: mdboom Date: 2008-09-18 13:09:01 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Fix interpolation in polar plots when theta values go negative. Thanks Jan Gillis for reporting. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/projections/polar.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-18 01:30:52 UTC (rev 6105) +++ trunk/matplotlib/CHANGELOG 2008-09-18 13:09:01 UTC (rev 6106) @@ -1,6 +1,8 @@ +2008-09-18 Fix polar interpolation to handle negative values of theta - MGD + 2008-09-14 Reorganized cbook and mlab methods related to numerical calculations that have little to do with the goals of those two - modules into a separate module numerical_methods.py + modules into a separate module numerical_methods.py Also, added ability to select points and stop point selection with keyboard in ginput and manual contour labeling code. Finally, fixed contour labeling bug. - DMK Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/polar.py 2008-09-18 01:30:52 UTC (rev 6105) +++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2008-09-18 13:09:01 UTC (rev 6106) @@ -56,6 +56,8 @@ def transform_path(self, path): vertices = path.vertices + t = vertices[:, 0:1] + t[t != (npy.pi * 2.0)] %= (npy.pi * 2.0) if len(vertices) == 2 and vertices[0, 0] == vertices[1, 0]: return Path(self.transform(vertices), path.codes) ipath = path.interpolated(self._resolution) @@ -168,6 +170,7 @@ """ self._rpad = 0.05 + self.resolution = kwargs.pop('resolution', self.RESOLUTION) Axes.__init__(self, *args, **kwargs) self.set_aspect('equal', adjustable='box', anchor='C') self.cla() @@ -195,7 +198,7 @@ self.transScale = TransformWrapper(IdentityTransform()) # A (possibly non-linear) projection on the (already scaled) data - self.transProjection = self.PolarTransform(self.RESOLUTION) + self.transProjection = self.PolarTransform(self.resolution) # An affine transformation on the data, generally to limit the # range of the axes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-09-18 13:14:23
|
Revision: 6107 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6107&view=rev Author: jdh2358 Date: 2008-09-18 20:14:18 +0000 (Thu, 18 Sep 2008) Log Message: ----------- updating pytz and dateutil -- HEAD will be broken temporarily Modified Paths: -------------- trunk/matplotlib/lib/dateutil/NEWS trunk/matplotlib/lib/dateutil/README trunk/matplotlib/setup.py Added Paths: ----------- trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2008e.tar.gz trunk/matplotlib/lib/pytz_old/ Removed Paths: ------------- trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2007f.tar.gz trunk/matplotlib/lib/pytz/ Modified: trunk/matplotlib/lib/dateutil/NEWS =================================================================== --- trunk/matplotlib/lib/dateutil/NEWS 2008-09-18 13:09:01 UTC (rev 6106) +++ trunk/matplotlib/lib/dateutil/NEWS 2008-09-18 20:14:18 UTC (rev 6107) @@ -1,3 +1,49 @@ +Version 1.4.1 +------------- + +- Updated timezone information. + + +Version 1.4 +----------- + +- Fixed another parser precision problem on conversion of decimal seconds + to microseconds, as reported by Erik Brown. Now these issues are gone + for real since it's not using floating point arithmetic anymore. + +- Fixed case where tzrange.utcoffset and tzrange.dst() might fail due + to a date being used where a datetime was expected (reported and fixed + by Lennart Regebro). + +- Prevent tzstr from introducing daylight timings in strings that didn't + specify them (reported by Lennart Regebro). + +- Calls like gettz("GMT+3") and gettz("UTC-2") will now return the + expected values, instead of the TZ variable behavior. + +- Fixed DST signal handling in zoneinfo files. Reported by + Nicholas F. Fabry and John-Mark Gurney. + + +Version 1.3 +----------- + +- Fixed precision problem on conversion of decimal seconds to + microseconds, as reported by Skip Montanaro. + +- Fixed bug in constructor of parser, and converted parser classes to + new-style classes. Original report and patch by Michael Elsd\xF6rfer. + +- Initialize tzid and comps in tz.py, to prevent the code from ever + raising a NameError (even with broken files). Johan Dahlin suggested + the fix after a pyflakes run. + +- Version is now published in dateutil.__version__, as requested + by Darren Dale. + +- All code is compatible with new-style division. + + Version 1.2 ----------- Modified: trunk/matplotlib/lib/dateutil/README =================================================================== --- trunk/matplotlib/lib/dateutil/README 2008-09-18 13:09:01 UTC (rev 6106) +++ trunk/matplotlib/lib/dateutil/README 2008-09-18 20:14:18 UTC (rev 6107) @@ -1,13 +1,3 @@ -The dateutil module packaged with matplotlib is copied from - http://labix.org/python-dateutil - -Do not make any changes in this copy of the code. They may be -overwritten with the next update from the original source. - -Below is the original README text from the distribution. - ------------------------------------------------------------------ - ## This file is in the moin format. The latest version is found ## at https://moin.conectiva.com.br/DateUtil Property changes on: trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2008e.tar.gz ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2008-09-18 13:09:01 UTC (rev 6106) +++ trunk/matplotlib/setup.py 2008-09-18 20:14:18 UTC (rev 6107) @@ -164,20 +164,19 @@ # only install pytz and dateutil if the user hasn't got them def add_pytz(): - packages.append('pytz') + packages = ['pytz'] resources = ['zone.tab', 'locales/pytz.pot'] - # install pytz subdirs - for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz', - 'zoneinfo')): + for dirpath, dirnames, filenames in os.walk(os.path.join('pytz', 'zoneinfo')): + # remove the 'pytz' part of the path if '.svn' not in dirpath: - # remove the 'lib/pytz' part of the path - basepath = dirpath.split(os.path.sep, 2)[2] + basepath = dirpath.split(os.path.sep, 1)[1] resources.extend([os.path.join(basepath, filename) for filename in filenames]) - package_data['pytz'] = resources - assert len(resources) > 10, 'pytz zoneinfo files not found!' -# packages.append('/'.join(dirpath.split(os.sep)[1:])) + package_data = {'pytz': resources} + assert len(resources) > 10, 'zoneinfo files not found!' + + def add_dateutil(): packages.append('dateutil') packages.append('dateutil/zoneinfo') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-09-18 13:26:08
|
Revision: 6109 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6109&view=rev Author: jdh2358 Date: 2008-09-18 20:26:06 +0000 (Thu, 18 Sep 2008) Log Message: ----------- fixed a pytz setup bug Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/setup.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-18 20:20:55 UTC (rev 6108) +++ trunk/matplotlib/CHANGELOG 2008-09-18 20:26:06 UTC (rev 6109) @@ -73,7 +73,7 @@ 2008-07-24 Rewrite of a significant portion of the clabel code (class ContourLabeler) to improve inlining. - DMK - + 2008-07-22 Added Barbs polygon collection (similar to Quiver) for plotting wind barbs. Added corresponding helpers to Axes and pyplot as well. (examples/pylab_examples/barb_demo.py shows it off.) - RMM @@ -163,7 +163,7 @@ 2008-06-24 Added "transparent" kwarg to savefig. - MGD -2008-06-24 Applied Stefan's patch to draw a sinle centered marker over +2008-06-24 Applied Stefan's patch to draw a single centered marker over a line with numpoints==1 - JDH 2008-06-23 Use splines to render circles in scatter plots - MGD Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2008-09-18 20:20:55 UTC (rev 6108) +++ trunk/matplotlib/setup.py 2008-09-18 20:26:06 UTC (rev 6109) @@ -166,7 +166,7 @@ def add_pytz(): packages = ['pytz'] resources = ['zone.tab', 'locales/pytz.pot'] - for dirpath, dirnames, filenames in os.walk(os.path.join('pytz', 'zoneinfo')): + for dirpath, dirnames, filenames in os.walk(os.path.join('lib', 'pytz', 'zoneinfo')): # remove the 'pytz' part of the path if '.svn' not in dirpath: basepath = dirpath.split(os.path.sep, 1)[1] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-09-18 16:36:46
|
Revision: 6112 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6112&view=rev Author: efiring Date: 2008-09-18 23:36:43 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Added angles kwarg to quiver, fixed bugs. Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-09-18 20:33:18 UTC (rev 6111) +++ trunk/matplotlib/API_CHANGES 2008-09-18 23:36:43 UTC (rev 6112) @@ -2,6 +2,9 @@ Changes for 0.98.x ================== +* Added angles kwarg to quiver for more flexible specification of + the arrow angles. + * Deprecated (raise NotImplementedError) all the mlab2 functions from matplotlib.mlab out of concern that some of them were not clean room implementations. @@ -19,7 +22,7 @@ maintained for the moment (in addition to their renamed versions), but they are depricated and will eventually be removed. -* Moved several function in mlab.py and cbook.py into a separate module +* Moved several function in mlab.py and cbook.py into a separate module numerical_methods.py because they were unrelated to the initial purpose of mlab or cbook and appeared more coherent elsewhere. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-18 20:33:18 UTC (rev 6111) +++ trunk/matplotlib/CHANGELOG 2008-09-18 23:36:43 UTC (rev 6112) @@ -1,11 +1,15 @@ +2008-09-18 Fixed quiver and quiverkey bugs (failure to scale properly + when resizing) and added additional methods for determining + the arrow angles - EF + 2008-09-18 Fix polar interpolation to handle negative values of theta - MGD 2008-09-14 Reorganized cbook and mlab methods related to numerical - calculations that have little to do with the goals of those two - modules into a separate module numerical_methods.py - Also, added ability to select points and stop point selection - with keyboard in ginput and manual contour labeling code. - Finally, fixed contour labeling bug. - DMK + calculations that have little to do with the goals of those two + modules into a separate module numerical_methods.py + Also, added ability to select points and stop point selection + with keyboard in ginput and manual contour labeling code. + Finally, fixed contour labeling bug. - DMK 2008-09-11 Fix backtick in Postscript output. - MGD Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008-09-18 20:33:18 UTC (rev 6111) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-09-18 23:36:43 UTC (rev 6112) @@ -72,17 +72,21 @@ * 'x' or 'y': *X* or *Y* data units - In all cases the arrow aspect ratio is 1, so that if *U*==*V* the - angle of the arrow on the plot is 45 degrees CCW from the - *x*-axis. - - The arrows scale differently depending on the units, however. For + The arrows scale differently depending on the units. For 'x' or 'y', the arrows get larger as one zooms in; for other units, the arrow size is independent of the zoom state. For 'width or 'height', the arrow size increases with the width and height of the axes, respectively, when the the window is resized; for 'dots' or 'inches', resizing does not change the arrows. + *angles*: ['uv' | 'xy' | array] + With the default 'uv', the arrow aspect ratio is 1, so that + if *U*==*V* the angle of the arrow on the plot is 45 degrees + CCW from the *x*-axis. + With 'xy', the arrow points from (x,y) to (x+u, y+v). + Alternatively, arbitrary angles may be specified as an array + of values in radians, CCW from the *x*-axis. + *scale*: [ None | float ] data units per arrow unit, e.g. m/s per plot width; a smaller scale parameter makes the arrow longer. If *None*, a simple @@ -244,7 +248,7 @@ __init__.__doc__ = _quiverkey_doc def _init(self): - if not self._initialized: + if True: ##not self._initialized: self._set_transform() _pivot = self.Q.pivot self.Q.pivot = self.pivot[self.labelpos] @@ -345,6 +349,7 @@ self.minshaft = kw.pop('minshaft', 1) self.minlength = kw.pop('minlength', 1) self.units = kw.pop('units', 'width') + self.angles = kw.pop('angles', 'uv') self.width = kw.pop('width', None) self.color = kw.pop('color', 'k') self.pivot = kw.pop('pivot', 'tail') @@ -402,7 +407,9 @@ """initialization delayed until first draw; allow time for axes setup. """ - if not self._initialized: + # It seems that there are not enough event notifications + # available to have this work on an as-needed basis at present. + if True: ##not self._initialized: trans = self._set_transform() ax = self.ax sx, sy = trans.inverted().transform_point( @@ -414,7 +421,7 @@ def draw(self, renderer): self._init() - if self._new_UV: + if self._new_UV or self.angles == 'xy': verts = self._make_verts(self.U, self.V) self.set_verts(verts, closed=False) self._new_UV = False @@ -452,6 +459,14 @@ self.set_transform(trans) return trans + def _angles(self, U, V, eps=0.001): + xy = self.ax.transData.transform(self.XY) + uv = ma.hstack((U[:,np.newaxis], V[:,np.newaxis])).filled(0) + xyp = self.ax.transData.transform(self.XY + eps * uv) + dxy = xyp - xy + ang = ma.arctan2(dxy[:,1], dxy[:,0]) + return ang + def _make_verts(self, U, V): uv = ma.asarray(U+V*1j) a = ma.absolute(uv) @@ -461,10 +476,12 @@ self.scale = scale length = a/(self.scale*self.width) X, Y = self._h_arrows(length) - # There seems to be a ma bug such that indexing - # a masked array with one element converts it to - # an ndarray. - theta = np.angle(ma.asarray(uv[..., np.newaxis]).filled(0)) + if self.angles == 'xy': + theta = self._angles(U, V).filled(0) + elif self.angles == 'uv': + theta = np.angle(ma.asarray(uv[..., np.newaxis]).filled(0)) + else: + theta = ma.asarray(self.angles).filled(0) xy = (X+Y*1j) * np.exp(1j*theta)*self.width xy = xy[:,:,np.newaxis] XY = ma.concatenate((xy.real, xy.imag), axis=2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-09-18 17:30:56
|
Revision: 6113 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6113&view=rev Author: efiring Date: 2008-09-19 00:30:54 +0000 (Fri, 19 Sep 2008) Log Message: ----------- Added an EllipseCollection class to collections.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/collections.py Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/ellipse_collection.py Added: trunk/matplotlib/examples/pylab_examples/ellipse_collection.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/ellipse_collection.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/ellipse_collection.py 2008-09-19 00:30:54 UTC (rev 6113) @@ -0,0 +1,34 @@ +import matplotlib.pyplot as plt +import numpy as np +from matplotlib.collections import EllipseCollection + +x = np.arange(10) +y = np.arange(15) +X, Y = np.meshgrid(x, y) + +XY = np.hstack((X.ravel()[:,np.newaxis], Y.ravel()[:,np.newaxis])) + +ww = X/10.0 +hh = Y/15.0 +aa = X*9 + + +ax = plt.subplot(1,1,1) + +ec = EllipseCollection( + ww, + hh, + aa, + units='x', + offsets=XY, + transOffset=ax.transData) +ec.set_array((X+Y).ravel()) +ax.add_collection(ec) +ax.autoscale_view() +ax.set_xlabel('X') +ax.set_ylabel('y') +cbar = plt.colorbar(ec) +cbar.set_label('X+Y') +plt.show() + + Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008-09-18 23:36:43 UTC (rev 6112) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008-09-19 00:30:54 UTC (rev 6113) @@ -10,7 +10,7 @@ """ import copy, math, warnings import numpy as np -import numpy.ma as ma +from numpy import ma import matplotlib as mpl import matplotlib.cbook as cbook import matplotlib.colors as _colors # avoid conflict with kwarg @@ -878,7 +878,7 @@ """ A collection of circles, drawn using splines. """ - def __init__(self, sizes): + def __init__(self, sizes, **kwargs): """ *sizes* Gives the area of the circle in points^2 @@ -900,7 +900,93 @@ for x in self._sizes] return Collection.draw(self, renderer) + def get_paths(self): + return self._paths +class EllipseCollection(Collection): + """ + A collection of ellipses, drawn using splines. + """ + def __init__(self, widths, heights, angles, units='points', **kwargs): + """ + *widths*: sequence + half-lengths of first axes (e.g., semi-major axis lengths) + + *heights*: sequence + half-lengths of second axes + + *angles*: sequence + angles of first axes, degrees CCW from the X-axis + + *units*: ['points' | 'inches' | 'dots' | 'width' | 'height' | 'x' | 'y'] + units in which majors and minors are given; 'width' and 'height' + refer to the dimensions of the axes, while 'x' and 'y' + refer to the *offsets* data units. + + Additional kwargs inherited from the base :class:`Collection`: + + %(Collection)s + """ + Collection.__init__(self,**kwargs) + self._widths = np.asarray(widths).ravel() + self._heights = np.asarray(heights).ravel() + self._angles = np.asarray(angles).ravel() *(np.pi/180.0) + self._units = units + self.set_transform(transforms.IdentityTransform()) + self._transforms = [] + self._paths = [mpath.Path.unit_circle()] + self._initialized = False + + + __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd + + def _init(self): + def on_dpi_change(fig): + self._transforms = [] + self.figure.callbacks.connect('dpi_changed', on_dpi_change) + self._initialized = True + + def set_transforms(self): + if not self._initialized: + self._init() + self._transforms = [] + ax = self.axes + fig = self.figure + if self._units in ('x', 'y'): + if self._units == 'x': + dx0 = ax.viewLim.width + dx1 = ax.bbox.width + else: + dx0 = ax.viewLim.height + dx1 = ax.bbox.height + sc = dx1/dx0 + else: + if self._units == 'inches': + sc = fig.dpi + elif self._units == 'points': + sc = fig.dpi / 72.0 + elif self._units == 'width': + sc = ax.bbox.width + elif self._units == 'height': + sc = ax.bbox.height + elif self._units == 'dots': + sc = 1.0 + else: + raise ValueError('unrecognized units: %s' % self._units) + + _affine = transforms.Affine2D + for x, y, a in zip(self._widths, self._heights, self._angles): + trans = _affine().scale(x * sc, y * sc).rotate(a) + self._transforms.append(trans) + + def draw(self, renderer): + if True: ###not self._transforms: + self.set_transforms() + return Collection.draw(self, renderer) + + def get_paths(self): + return self._paths + class PatchCollection(Collection): """ A generic collection of patches. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-09-20 03:21:45
|
Revision: 6115 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6115&view=rev Author: efiring Date: 2008-09-20 03:21:19 +0000 (Sat, 20 Sep 2008) Log Message: ----------- fix bug in "angles='xy'" support in quiver Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008-09-19 00:36:10 UTC (rev 6114) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008-09-20 03:21:19 UTC (rev 6115) @@ -50,6 +50,7 @@ 'customize_rc.py', 'date_demo1.py', 'date_demo2.py', + 'ellipse_collection.py', 'equal_aspect_ratio.py', 'errorbar_limits.py', 'fancybox_demo.py', Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008-09-19 00:36:10 UTC (rev 6114) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-09-20 03:21:19 UTC (rev 6115) @@ -477,7 +477,7 @@ length = a/(self.scale*self.width) X, Y = self._h_arrows(length) if self.angles == 'xy': - theta = self._angles(U, V).filled(0) + theta = self._angles(U, V).filled(0)[:,np.newaxis] elif self.angles == 'uv': theta = np.angle(ma.asarray(uv[..., np.newaxis]).filled(0)) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-09-24 08:58:25
|
Revision: 6119 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6119&view=rev Author: mmetz_bn Date: 2008-09-24 08:58:16 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Separate drawstyles and linestyles for lines Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-23 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/CHANGELOG 2008-09-24 08:58:16 UTC (rev 6119) @@ -1,3 +1,7 @@ +2008-09-24 Introduce drawstyles for lines. Transparently split linestyles + like 'steps--' into drawstyle 'steps' and linestyle '--'. + Legends always use drawstyle 'default'. - MM + 2008-09-18 Fixed quiver and quiverkey bugs (failure to scale properly when resizing) and added additional methods for determining the arrow angles - EF Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-09-23 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-09-24 08:58:16 UTC (rev 6119) @@ -263,6 +263,7 @@ self._set_artist_props(legline) # after update legline.set_clip_box(None) legline.set_clip_path(None) + legline.set_drawstyle('default') ret.append(legline) legline.set_marker('None') Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008-09-23 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008-09-24 08:58:16 UTC (rev 6119) @@ -11,7 +11,8 @@ from matplotlib import verbose import artist from artist import Artist -from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent +from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent,\ +flatten from colors import colorConverter from path import Path from transforms import Affine2D, Bbox, TransformedPath, IdentityTransform @@ -76,14 +77,24 @@ '--' : '_draw_dashed', '-.' : '_draw_dash_dot', ':' : '_draw_dotted', - 'steps' : '_draw_steps_pre', - 'steps-mid' : '_draw_steps_mid', - 'steps-pre' : '_draw_steps_pre', - 'steps-post' : '_draw_steps_post', 'None' : '_draw_nothing', ' ' : '_draw_nothing', '' : '_draw_nothing', } + + _drawStyles_l = { + 'default' : '_draw_lines', + 'steps-mid' : '_draw_steps_mid', + 'steps-pre' : '_draw_steps_pre', + 'steps-post' : '_draw_steps_post', + } + + _drawStyles_s = { + 'steps' : '_draw_steps_pre', + } + drawStyles = {} + drawStyles.update(_drawStyles_l) + drawStyles.update(_drawStyles_s) markers = _markers = { # hidden names deprecated '.' : '_draw_point', @@ -155,6 +166,7 @@ dash_joinstyle = None, solid_joinstyle = None, pickradius = 5, + drawstyle = None, **kwargs ): """ @@ -185,6 +197,8 @@ if solid_capstyle is None : solid_capstyle=rcParams['lines.solid_capstyle'] if solid_joinstyle is None : solid_joinstyle=rcParams['lines.solid_joinstyle'] + if drawstyle is None : drawstyle='default' + self.set_dash_capstyle(dash_capstyle) self.set_dash_joinstyle(dash_joinstyle) self.set_solid_capstyle(solid_capstyle) @@ -192,6 +206,7 @@ self.set_linestyle(linestyle) + self.set_drawstyle(drawstyle) self.set_linewidth(linewidth) self.set_color(color) self.set_marker(marker) @@ -423,8 +438,10 @@ funcname = self._lineStyles.get(self._linestyle, '_draw_nothing') if funcname != '_draw_nothing': tpath, affine = self._transformed_path.get_transformed_path_and_affine() - lineFunc = getattr(self, funcname) - lineFunc(renderer, gc, tpath, affine.frozen()) + self._lineFunc = getattr(self, funcname) + funcname = self.drawStyles.get(self._drawstyle, '_draw_lines') + drawFunc = getattr(self, funcname) + drawFunc(renderer, gc, tpath, affine.frozen()) if self._marker is not None: gc = renderer.new_gc() @@ -442,6 +459,7 @@ def get_antialiased(self): return self._antialiased def get_color(self): return self._color + def get_drawstyle(self): return self._drawstyle def get_linestyle(self): return self._linestyle def get_linewidth(self): return self._linewidth @@ -543,6 +561,18 @@ """ self._color = color + def set_drawstyle(self, drawstyle): + """ + Set the drawstyle of the plot + + 'default' connects the points with lines. The steps variants + produce step-plots. 'steps' is equivalent to 'steps-pre' and + is maintained for backward-compatibility. + + ACCEPTS: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ] + """ + self._drawstyle = drawstyle + def set_linewidth(self, w): """ Set the line width in points @@ -558,8 +588,20 @@ 'steps' is equivalent to 'steps-pre' and is maintained for backward-compatibility. - ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ] + ACCEPTS: [ '-' | '--' | '-.' | ':' | 'None' | ' ' | '' ] and + any drawstyle in combination with a linestyle, e.g. 'steps--'. """ + + # handle long drawstyle names before short ones ! + for ds in flatten([k.keys() for k in (self._drawStyles_l, + self._drawStyles_s)], is_string_like): + if linestyle.startswith(ds): + self.set_drawstyle(ds) + if len(linestyle) > len(ds): + linestyle = linestyle[len(ds):] + else: + linestyle = '-' + if linestyle not in self._lineStyles: if ls_mapper.has_key(linestyle): linestyle = ls_mapper[linestyle] @@ -569,7 +611,6 @@ if linestyle in [' ','']: linestyle = 'None' self._linestyle = linestyle - self._lineFunc = self._lineStyles[linestyle] def set_marker(self, marker): """ @@ -660,15 +701,10 @@ self.set_linestyle('--') self._dashSeq = seq # TODO: offset ignored for now - def _draw_nothing(self, *args, **kwargs): - pass + def _draw_lines(self, renderer, gc, path, trans): + self._lineFunc(renderer, gc, path, trans) - def _draw_solid(self, renderer, gc, path, trans): - gc.set_linestyle('solid') - renderer.draw_path(gc, path, trans) - - def _draw_steps_pre(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices)-1, 2), np.float_) @@ -678,9 +714,8 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) - def _draw_steps_post(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices)-1, 2), np.float_) @@ -690,9 +725,8 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) - def _draw_steps_mid(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices), 2), np.float_) @@ -705,9 +739,16 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) + def _draw_nothing(self, *args, **kwargs): + pass + + def _draw_solid(self, renderer, gc, path, trans): + gc.set_linestyle('solid') + renderer.draw_path(gc, path, trans) + def _draw_dashed(self, renderer, gc, path, trans): gc.set_linestyle('dashed') if self._dashSeq is not None: @@ -990,6 +1031,7 @@ self._linestyle = other._linestyle self._marker = other._marker + self._drawstyle = other._drawstyle def _get_rgb_face(self): @@ -1239,6 +1281,7 @@ lineStyles = Line2D._lineStyles lineMarkers = Line2D._markers +drawStyles = Line2D.drawStyles artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-09-28 00:44:16
|
Revision: 6127 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6127&view=rev Author: efiring Date: 2008-09-28 00:44:08 +0000 (Sun, 28 Sep 2008) Log Message: ----------- Enhancement to Axes.spy, and bugfixes: figlegend was not plotting markers; plot could not handle empty input arrays. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/transforms.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/CHANGELOG 2008-09-28 00:44:08 UTC (rev 6127) @@ -1,3 +1,7 @@ +2008-09-27 Allow spy to ignore zero values in sparse arrays, based + on patch by Tony Yu. Also fixed plot to handle empty + data arrays, and fixed handling of markers in figlegend. - EF + 2008-09-24 Introduce drawstyles for lines. Transparently split linestyles like 'steps--' into drawstyle 'steps' and linestyle '--'. Legends always use drawstyle 'default'. - MM @@ -81,7 +85,7 @@ 2008-07-24 Rewrite of a significant portion of the clabel code (class ContourLabeler) to improve inlining. - DMK - + 2008-07-22 Added Barbs polygon collection (similar to Quiver) for plotting wind barbs. Added corresponding helpers to Axes and pyplot as well. (examples/pylab_examples/barb_demo.py shows it off.) - RMM Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-09-28 00:44:08 UTC (rev 6127) @@ -309,7 +309,8 @@ x = self.axes.convert_xunits(x) y = self.axes.convert_yunits(y) facecolor = self._get_next_cycle_color() - seg = mpatches.Polygon(zip(x, y), + seg = mpatches.Polygon(np.hstack( + (x[:,np.newaxis],y[:,np.newaxis])), facecolor = facecolor, fill=True, closed=closed @@ -355,7 +356,8 @@ facecolor = color x = self.axes.convert_xunits(x) y = self.axes.convert_yunits(y) - seg = mpatches.Polygon(zip(x, y), + seg = mpatches.Polygon(np.hstack( + (x[:,np.newaxis],y[:,np.newaxis])), facecolor = facecolor, fill=True, closed=closed @@ -1282,9 +1284,10 @@ line._remove_method = lambda h: self.lines.remove(h) def _update_line_limits(self, line): - self.dataLim.update_from_path(line.get_path(), - self.ignore_existing_data_limits) - self.ignore_existing_data_limits = False + p = line.get_path() + if p.vertices.size > 0: + self.dataLim.update_from_path(p, self.ignore_existing_data_limits) + self.ignore_existing_data_limits = False def add_patch(self, p): """ @@ -1300,21 +1303,26 @@ self.patches.append(p) p._remove_method = lambda h: self.patches.remove(h) - def _update_patch_limits(self, p): + def _update_patch_limits(self, patch): 'update the data limits for patch *p*' # hist can add zero height Rectangles, which is useful to keep # the bins, counts and patches lined up, but it throws off log # scaling. We'll ignore rects with zero height or width in # the auto-scaling - if isinstance(p, mpatches.Rectangle) and (p.get_width()==0. or p.get_height()==0.): + + if (isinstance(patch, mpatches.Rectangle) and + (patch.get_width()==0 or patch.get_height()==0)): return - vertices = p.get_patch_transform().transform(p.get_path().vertices) - if p.get_data_transform() != self.transData: - transform = p.get_data_transform() + self.transData.inverted() - xys = transform.transform(vertices) - # Something is wrong--xys is never used. - self.update_datalim(vertices) + vertices = patch.get_path().vertices + if vertices.size > 0: + xys = patch.get_patch_transform().transform(vertices) + if patch.get_data_transform() != self.transData: + transform = (patch.get_data_transform() + + self.transData.inverted()) + xys = transform.transform(xys) + self.update_datalim(xys) + def add_table(self, tab): ''' Add a :class:`~matplotlib.tables.Table` instance to the @@ -6645,7 +6653,7 @@ return Pxx, freqs, bins, im def spy(self, Z, precision=None, marker=None, markersize=None, - aspect='equal', **kwargs): + aspect='equal', **kwargs): """ call signature:: @@ -6657,6 +6665,10 @@ If *precision* is *None*, any non-zero value will be plotted; else, values of :math:`|Z| > precision` will be plotted. + For :class:`scipy.sparse.spmatrix` instances, there is a + special case: if *precision* is 0, any value present in + the array will be plotted, even if it is identically zero. + The array will be plotted as it would be printed, with the first index (row) increasing down and the second index (column) increasing to the right. @@ -6707,9 +6719,9 @@ * ',' pixel """ + if marker is None and markersize is None and hasattr(Z, 'tocoo'): + marker = 's' if marker is None and markersize is None: - if hasattr(Z, 'tocoo'): - raise TypeError, "Image mode does not support scipy.sparse arrays" Z = np.asarray(Z) if precision is None: mask = Z!=0. else: mask = np.absolute(Z)>precision @@ -6723,23 +6735,33 @@ else: if hasattr(Z, 'tocoo'): c = Z.tocoo() - y = c.row - x = c.col - z = c.data + if precision == 0: + y = c.row + x = c.col + else: + if precision is None: + nonzero = c.data != 0. + else: + nonzero = np.absolute(c.data) > precision + y = c.row[nonzero] + x = c.col[nonzero] else: Z = np.asarray(Z) - if precision is None: mask = Z!=0. - else: mask = np.absolute(Z)>precision - y,x,z = mlab.get_xyz_where(mask, mask) + if precision is None: + nonzero = Z!=0. + else: + nonzero = np.absolute(Z)>precision + y, x = np.nonzero(nonzero) if marker is None: marker = 's' if markersize is None: markersize = 10 - lines = self.plot(x, y, linestyle='None', + marks = mlines.Line2D(x, y, linestyle='None', marker=marker, markersize=markersize, **kwargs) + self.add_line(marks) nr, nc = Z.shape self.set_xlim(xmin=-0.5, xmax=nc-0.5) self.set_ylim(ymin=nr-0.5, ymax=-0.5) self.set_aspect(aspect) - ret = lines + ret = marks self.title.set_y(1.05) self.xaxis.tick_top() self.xaxis.set_ticks_position('both') Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-09-28 00:44:08 UTC (rev 6127) @@ -264,13 +264,15 @@ legline.set_clip_box(None) legline.set_clip_path(None) legline.set_drawstyle('default') + legline.set_marker('None') ret.append(legline) - legline.set_marker('None') legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)]) legline_marker.update_from(handle) + self._set_artist_props(legline_marker) + legline_marker.set_clip_box(None) + legline_marker.set_clip_path(None) legline_marker.set_linestyle('None') - self._set_artist_props(legline_marker) # we don't want to add this to the return list because # the texts and handles are assumed to be in one-to-one # correpondence. Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008-09-28 00:44:08 UTC (rev 6127) @@ -81,14 +81,14 @@ ' ' : '_draw_nothing', '' : '_draw_nothing', } - + _drawStyles_l = { 'default' : '_draw_lines', 'steps-mid' : '_draw_steps_mid', 'steps-pre' : '_draw_steps_pre', 'steps-post' : '_draw_steps_post', } - + _drawStyles_s = { 'steps' : '_draw_steps_pre', } Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008-09-28 00:44:08 UTC (rev 6127) @@ -408,7 +408,7 @@ return self._rect_transform def contains(self, mouseevent): - # special case the degernate rectangle + # special case the degenerate rectangle if self._width==0 or self._height==0: return False, {} Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2008-09-28 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-09-28 00:44:08 UTC (rev 6127) @@ -801,6 +801,9 @@ if ignore is None: ignore = self._ignore + if path.vertices.size == 0: + return + points, minpos, changed = update_path_extents( path, None, self._points, self._minpos, ignore) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-09-30 20:08:13
|
Revision: 6137 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6137&view=rev Author: mdboom Date: 2008-09-30 20:07:54 +0000 (Tue, 30 Sep 2008) Log Message: ----------- [ 2138392 ] API doc for add_subplot() Also fixing numerous problems with the documentation build. It seems that the change in plot_directive.py to use the "code" module to run scripts interferes with i18n in Sphinx (due to the overloading of '_' as a symbol). Changed to use the fewer-moving-parts imp.load_module() instead. Modified Paths: -------------- trunk/matplotlib/doc/faq/howto_faq.rst trunk/matplotlib/doc/make.py trunk/matplotlib/doc/sphinxext/plot_directive.py trunk/matplotlib/examples/pylab_examples/findobj_demo.py trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/doc/faq/howto_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/howto_faq.rst 2008-09-30 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2008-09-30 20:07:54 UTC (rev 6137) @@ -117,7 +117,7 @@ How do I automatically make room for my tick labels? ==================================================== -In most use cases, it is enought to simpy change the subplots adjust +In most use cases, it is enough to simpy change the subplots adjust parameters as described in :ref:`howto-subplots-adjust`. But in some cases, you don't know ahead of time what your tick labels will be, or how large they will be (data and labels outside your control may be Modified: trunk/matplotlib/doc/make.py =================================================================== --- trunk/matplotlib/doc/make.py 2008-09-30 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/make.py 2008-09-30 20:07:54 UTC (rev 6137) @@ -85,7 +85,7 @@ for arg in sys.argv[1:]: func = funcd.get(arg) if func is None: - raise SystemExit('Do not know how to handle %s; valid args are'%( + raise SystemExit('Do not know how to handle %s; valid args are %s'%( arg, funcd.keys())) func() else: Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-09-30 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-09-30 20:07:54 UTC (rev 6137) @@ -13,7 +13,7 @@ source will be included inline, as well as a link to the source. """ -import sys, os, glob, shutil, code +import sys, os, glob, shutil, imp from docutils.parsers.rst import directives try: @@ -30,12 +30,10 @@ matplotlib.use('Agg') import matplotlib.pyplot as plt -#import IPython.Shell -#mplshell = IPython.Shell.MatplotlibShell('mpl') -console = code.InteractiveConsole() def runfile(fname): - source = file(fname).read() - return console.runsource(source) + fd = open(fname) + module = imp.load_module("__main__", fd, fname, ('py', 'r', imp.PY_SOURCE)) + return module options = {'alt': directives.unchanged, 'height': directives.length_or_unitless, Modified: trunk/matplotlib/examples/pylab_examples/findobj_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008-09-30 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008-09-30 20:07:54 UTC (rev 6137) @@ -1,5 +1,5 @@ """ -Recursuvely find all objects that match some criteria +Recursively find all objects that match some criteria """ import numpy as np import matplotlib.pyplot as plt Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-09-30 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-09-30 20:07:54 UTC (rev 6137) @@ -633,21 +633,23 @@ fig.add_subplot(111, polar=True) # add a polar subplot fig.add_subplot(sub) # add Subplot instance sub - *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus *projection*, which chooses - a projection type for the axes. (For backward compatibility, - *polar=True* may also be provided, which is equivalent to - *projection='polar'*). Valid values for *projection* are: %s. - Some of these projections support additional *kwargs*, which may - be provided to :meth:`add_axes`. + *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus + *projection*, which chooses a projection type for the axes. + (For backward compatibility, *polar=True* may also be + provided, which is equivalent to *projection='polar'*). Valid + values for *projection* are: %s. Some of these projections + support additional *kwargs*, which may be provided to + :meth:`add_axes`. The :class:`~matplotlib.axes.Axes` instance will be returned. - If the figure already has a subplot with key *args*, *kwargs* then it will - simply make that subplot current and return it + If the figure already has a subplot with key (*args*, + *kwargs*) then it will simply make that subplot current and + return it. The following kwargs are supported: %s - """ % (", ".join(get_projection_names()), "%(Axes)s") + """ key = self._make_key(*args, **kwargs) if self._seen.has_key(key): @@ -680,7 +682,8 @@ self.sca(a) self._seen[key] = a return a - add_subplot.__doc__ = dedent(add_subplot.__doc__) % artist.kwdocd + add_subplot.__doc__ = dedent(add_subplot.__doc__) % ( + ", ".join(get_projection_names()), "%(Axes)s") % artist.kwdocd def clf(self): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-10-02 13:57:03
|
Revision: 6142 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6142&view=rev Author: mdboom Date: 2008-10-02 13:38:50 +0000 (Thu, 02 Oct 2008) Log Message: ----------- Fix all Python 2.6 deprecation warnings. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py trunk/matplotlib/lib/matplotlib/font_manager.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/transforms.py trunk/matplotlib/lib/pytz/tzinfo.py trunk/matplotlib/setupext.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -93,7 +93,7 @@ __revision__ = '$Revision$' __date__ = '$Date$' -import md5, os, re, shutil, sys, warnings +import os, re, shutil, sys, warnings import distutils.sysconfig @@ -234,7 +234,7 @@ if always is True, the report will occur on every function call; otherwise only on the first time the function is called """ - assert(callable, func) + assert callable(func) def wrapper(*args, **kwargs): ret = func(*args, **kwargs) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -25,7 +25,11 @@ def _fn_name(): return sys._getframe(1).f_code.co_name -import cairo +try: + import cairo +except ImportError: + raise ImportError("Cairo backend requires that pycairo is installed.") + _version_required = (1,2,0) if cairo.version_info < _version_required: raise ImportError ("Pycairo %d.%d.%d is installed\n" Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -3,9 +3,13 @@ import os, sys def fn_name(): return sys._getframe(1).f_code.co_name -import gobject -import gtk; gdk = gtk.gdk -import pango +try: + import gobject + import gtk; gdk = gtk.gdk + import pango +except ImportError: + raise ImportError("Gtk* backend requires pygtk to be installed.") + pygtk_version_required = (2,2,0) if gtk.pygtk_version < pygtk_version_required: raise ImportError ("PyGTK %d.%d.%d is installed\n" Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -17,7 +17,10 @@ from cStringIO import StringIO from datetime import datetime from math import ceil, cos, floor, pi, sin -from sets import Set +try: + set +except NameError: + from sets import Set as set import matplotlib from matplotlib import __version__, rcParams, get_data_path @@ -692,7 +695,7 @@ cmap = font.get_charmap() glyph_ids = [] differences = [] - multi_byte_chars = Set() + multi_byte_chars = set() for c in characters: ccode = c gind = cmap.get(ccode) or 0 @@ -1215,14 +1218,14 @@ fname = font.fname realpath, stat_key = get_realpath_and_stat(fname) used_characters = self.used_characters.setdefault( - stat_key, (realpath, Set())) + stat_key, (realpath, set())) used_characters[1].update([ord(x) for x in s]) def merge_used_characters(self, other): - for stat_key, (realpath, set) in other.items(): + for stat_key, (realpath, charset) in other.items(): used_characters = self.used_characters.setdefault( - stat_key, (realpath, Set())) - used_characters[1].update(set) + stat_key, (realpath, set())) + used_characters[1].update(charset) def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): #print >>sys.stderr, "draw_image called" Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -36,7 +36,10 @@ import numpy as npy import binascii import re -from sets import Set +try: + set +except NameError: + from sets import Set as set if sys.platform.startswith('win'): cmd_split = '&' else: cmd_split = ';' @@ -173,14 +176,14 @@ each font.""" realpath, stat_key = get_realpath_and_stat(font.fname) used_characters = self.used_characters.setdefault( - stat_key, (realpath, Set())) + stat_key, (realpath, set())) used_characters[1].update([ord(x) for x in s]) def merge_used_characters(self, other): - for stat_key, (realpath, set) in other.items(): + for stat_key, (realpath, charset) in other.items(): used_characters = self.used_characters.setdefault( - stat_key, (realpath, Set())) - used_characters[1].update(set) + stat_key, (realpath, set())) + used_characters[1].update(charset) def set_color(self, r, g, b, store=1): if (r,g,b) != self.color: Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -13,7 +13,10 @@ from matplotlib.mathtext import MathTextParser from matplotlib.widgets import SubplotTool -import qt +try: + import qt +except ImportError: + raise ImportError("Qt backend requires pyqt to be installed.") backend_version = "0.9.1" def fn_name(): return sys._getframe(1).f_code.co_name Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -13,7 +13,10 @@ from matplotlib.mathtext import MathTextParser from matplotlib.widgets import SubplotTool -from PyQt4 import QtCore, QtGui, Qt +try: + from PyQt4 import QtCore, QtGui, Qt +except ImportError: + raise ImportError("Qt4 backend requires that PyQt4 is installed.") backend_version = "0.9.1" def fn_name(): return sys._getframe(1).f_code.co_name Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -112,8 +112,7 @@ import wx backend_version = wx.VERSION_STRING except: - print >>sys.stderr, "Matplotlib backend_wx requires wxPython be installed" - sys.exit() + raise ImportError("Matplotlib backend_wx requires wxPython be installed") #!!! this is the call that is causing the exception swallowing !!! #wx.InitAllImageHandlers() Modified: trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py =================================================================== --- trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -1,10 +1,8 @@ import warnings -# 2.3 compatibility try: set except NameError: - import sets - set = sets.Set + from sets import Set as set import numpy as np @@ -98,7 +96,7 @@ # Find the indices of the unique entries j_sorted = np.lexsort(keys=(self.x, self.y)) mask_unique = np.hstack([ - True, + True, (np.diff(self.x[j_sorted]) != 0) | (np.diff(self.y[j_sorted]) != 0), ]) return j_sorted[mask_unique] Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -34,7 +34,10 @@ """ import os, sys, glob -from sets import Set +try: + set +except NameError: + from sets import Set as set import matplotlib from matplotlib import afm from matplotlib import ft2font @@ -1036,7 +1039,7 @@ verbose.report('findfont returning %s'%fname, 'debug') return fname - font_family_aliases = Set(['serif', 'sans-serif', 'cursive', + font_family_aliases = set(['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace', 'sans']) for name in prop.get_family(): Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -175,7 +175,10 @@ import os from cStringIO import StringIO from math import ceil -from sets import Set +try: + set +except NameError: + from sets import Set as set import unicodedata from warnings import warn @@ -531,7 +534,7 @@ info = self._get_info(facename, font_class, sym, fontsize, dpi) realpath, stat_key = get_realpath_and_stat(info.font.fname) used_characters = self.used_characters.setdefault( - stat_key, (realpath, Set())) + stat_key, (realpath, set())) used_characters[1].add(info.num) self.mathtext_backend.render_glyph(ox, oy, info) @@ -704,7 +707,7 @@ self.fontmap[val] = fullpath - _slanted_symbols = Set(r"\int \oint".split()) + _slanted_symbols = set(r"\int \oint".split()) def _get_glyph(self, fontname, font_class, sym, fontsize): symbol_name = None @@ -816,7 +819,7 @@ font = findfont(prop) self.fontmap['ex'] = font - _slanted_symbols = Set(r"\int \oint".split()) + _slanted_symbols = set(r"\int \oint".split()) def _map_virtual_font(self, fontname, font_class, uniindex): return fontname, uniindex @@ -1967,7 +1970,7 @@ return empty class Parser(object): - _binary_operators = Set(r''' + _binary_operators = set(r''' + * \pm \sqcap \rhd \mp \sqcup \unlhd @@ -1982,7 +1985,7 @@ \cup \triangleright \ddagger \uplus \lhd \amalg'''.split()) - _relation_symbols = Set(r''' + _relation_symbols = set(r''' = < > : \leq \geq \equiv \models \prec \succ \sim \perp @@ -1995,7 +1998,7 @@ \in \ni \propto \vdash \dashv'''.split()) - _arrow_symbols = Set(r''' + _arrow_symbols = set(r''' \leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow \Uparrow \rightarrow \longrightarrow \downarrow @@ -2010,32 +2013,32 @@ _spaced_symbols = _binary_operators | _relation_symbols | _arrow_symbols - _punctuation_symbols = Set(r', ; . ! \ldotp \cdotp'.split()) + _punctuation_symbols = set(r', ; . ! \ldotp \cdotp'.split()) - _overunder_symbols = Set(r''' + _overunder_symbols = set(r''' \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee \bigwedge \bigodot \bigotimes \bigoplus \biguplus '''.split()) - _overunder_functions = Set( + _overunder_functions = set( r"lim liminf limsup sup max min".split()) - _dropsub_symbols = Set(r'''\int \oint'''.split()) + _dropsub_symbols = set(r'''\int \oint'''.split()) - _fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split()) + _fontnames = set("rm cal it tt sf bf default bb frak circled scr".split()) - _function_names = Set(""" + _function_names = set(""" arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan coth inf max tanh""".split()) - _ambiDelim = Set(r""" + _ambiDelim = set(r""" | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow .""".split()) - _leftDelim = Set(r"( [ { \lfloor \langle \lceil".split()) + _leftDelim = set(r"( [ { \lfloor \langle \lceil".split()) - _rightDelim = Set(r") ] } \rfloor \rangle \rceil".split()) + _rightDelim = set(r") ] } \rfloor \rangle \rceil".split()) def __init__(self): # All forward declarations are here @@ -2381,7 +2384,7 @@ r'^' : r'\circumflexaccent' } - _wide_accents = Set(r"widehat widetilde".split()) + _wide_accents = set(r"widehat widetilde".split()) def accent(self, s, loc, toks): assert(len(toks)==1) Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -96,7 +96,8 @@ # set is a new builtin function in 2.4; delete the following when # support for 2.3 is dropped. -try: set +try: + set except NameError: from sets import Set as set Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -36,7 +36,10 @@ from weakref import WeakKeyDictionary import warnings -import sets +try: + set +except NameError: + from sets import Set as set import cbook from path import Path @@ -161,7 +164,7 @@ fobj: A Python file-like object """ - seen = sets.Set() + seen = set() def recurse(root): if root in seen: Modified: trunk/matplotlib/lib/pytz/tzinfo.py =================================================================== --- trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -2,7 +2,10 @@ from datetime import datetime, timedelta, tzinfo from bisect import bisect_right -from sets import Set +try: + set +except NameError: + from sets import Set as set import pytz @@ -71,7 +74,7 @@ def fromutc(self, dt): '''See datetime.tzinfo.fromutc''' return (dt + self._utcoffset).replace(tzinfo=self) - + def utcoffset(self,dt): '''See datetime.tzinfo.utcoffset''' return self._utcoffset @@ -101,16 +104,16 @@ def __reduce__(self): # Special pickle to zone remains a singleton and to cope with - # database changes. + # database changes. return pytz._p, (self.zone,) class DstTzInfo(BaseTzInfo): '''A timezone that has a variable offset from UTC - + The offset might change if daylight savings time comes into effect, - or at a point in history when the region decides to change their - timezone definition. + or at a point in history when the region decides to change their + timezone definition. ''' # Overridden in subclass @@ -191,13 +194,13 @@ def localize(self, dt, is_dst=False): '''Convert naive time to local time. - + This method should be used to construct localtimes, rather than passing a tzinfo argument to a datetime constructor. is_dst is used to determine the correct timezone in the ambigous period at the end of daylight savings time. - + >>> from pytz import timezone >>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)' >>> amdam = timezone('Europe/Amsterdam') @@ -226,7 +229,7 @@ AmbiguousTimeError: 2004-10-31 02:00:00 is_dst defaults to False - + >>> amdam.localize(dt) == amdam.localize(dt, False) True @@ -238,7 +241,7 @@ # but we might end up with two if we are in the end-of-DST # transition period. Or possibly more in some particularly confused # location... - possible_loc_dt = Set() + possible_loc_dt = set() for tzinfo in self._tzinfos.values(): loc_dt = tzinfo.normalize(dt.replace(tzinfo=tzinfo)) if loc_dt.replace(tzinfo=None) == dt: @@ -281,7 +284,7 @@ ) filtered_possible_loc_dt.sort(mycmp) return filtered_possible_loc_dt[0] - + def utcoffset(self, dt): '''See datetime.tzinfo.utcoffset''' return self._utcoffset @@ -328,11 +331,11 @@ See DstTzInfo.normalize() for more info ''' - + def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None): """Factory function for unpickling pytz tzinfo instances. - + This is shared for both StaticTzInfo and DstTzInfo instances, because database changes could cause a zones implementation to switch between these two base classes and we can't break pickles on a pytz version Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2008-10-01 14:20:28 UTC (rev 6141) +++ trunk/matplotlib/setupext.py 2008-10-02 13:38:50 UTC (rev 6142) @@ -43,8 +43,8 @@ import os import re +import subprocess - basedir = { 'win32' : ['win32_static',], 'linux2' : ['/usr/local', '/usr'], @@ -64,7 +64,6 @@ import sys, os, stat if sys.platform != 'win32': import commands -from sets import Set from textwrap import fill from distutils.core import Extension import glob @@ -188,6 +187,14 @@ pass print_status = print_message = print_raw = print_line +def run_child_process(cmd): + p = subprocess.Popen(cmd, shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + close_fds=True) + return p.stdin, p.stdout + class CleanUpFile: """CleanUpFile deletes the specified filename when self is destroyed.""" def __init__(self, name): @@ -499,7 +506,7 @@ def check_for_dvipng(): try: - stdin, stdout = os.popen4('dvipng -version') + stdin, stdout = run_child_process('dvipng -version') print_status("dvipng", stdout.readlines()[1].split()[-1]) return True except (IndexError, ValueError): @@ -512,7 +519,7 @@ command = 'gswin32c --version' else: command = 'gs --version' - stdin, stdout = os.popen4(command) + stdin, stdout = run_child_process(command) print_status("ghostscript", stdout.read()[:-1]) return True except (IndexError, ValueError): @@ -521,7 +528,7 @@ def check_for_latex(): try: - stdin, stdout = os.popen4('latex -version') + stdin, stdout = run_child_process('latex -version') line = stdout.readlines()[0] pattern = '3\.1\d+' match = re.search(pattern, line) @@ -533,7 +540,7 @@ def check_for_pdftops(): try: - stdin, stdout = os.popen4('pdftops -v') + stdin, stdout = run_child_process('pdftops -v') for line in stdout.readlines(): if 'version' in line: print_status("pdftops", line.split()[-1]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-10-02 14:28:53
|
Revision: 6143 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6143&view=rev Author: mdboom Date: 2008-10-02 14:28:45 +0000 (Thu, 02 Oct 2008) Log Message: ----------- Fix some python2.6 -3 warnings. (mainly usage of has_key) Modified Paths: -------------- trunk/matplotlib/boilerplate.py trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/_pylab_helpers.py trunk/matplotlib/lib/matplotlib/afm.py trunk/matplotlib/lib/matplotlib/artist.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/config/cutils.py trunk/matplotlib/lib/matplotlib/config/mplconfig.py trunk/matplotlib/lib/matplotlib/config/rcparams.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/font_manager.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/scale.py trunk/matplotlib/lib/matplotlib/table.py trunk/matplotlib/lib/matplotlib/text.py trunk/matplotlib/lib/matplotlib/ticker.py trunk/matplotlib/lib/pytz/tzinfo.py trunk/matplotlib/setupext.py trunk/matplotlib/src/_tkagg.cpp Modified: trunk/matplotlib/boilerplate.py =================================================================== --- trunk/matplotlib/boilerplate.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/boilerplate.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -114,7 +114,7 @@ for func in _plotcommands: - if cmappable.has_key(func): + if func in cmappable: mappable = cmappable[func] else: mappable = '' Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -443,7 +443,7 @@ def _get_data_path(): 'get the path to matplotlib data' - if os.environ.has_key('MATPLOTLIBDATA'): + if 'MATPLOTLIBDATA' in os.environ: path = os.environ['MATPLOTLIBDATA'] if not os.path.isdir(path): raise RuntimeError('Path in environment MATPLOTLIBDATA not a directory') @@ -535,7 +535,7 @@ fname = os.path.join( os.getcwd(), 'matplotlibrc') if os.path.exists(fname): return fname - if os.environ.has_key('MATPLOTLIBRC'): + if 'MATPLOTLIBRC' in os.environ: path = os.environ['MATPLOTLIBRC'] if os.path.exists(path): fname = os.path.join(path, 'matplotlibrc') @@ -637,7 +637,7 @@ verbose.set_fileo(ret['verbose.fileo']) for key, (val, line, cnt) in rc_temp.iteritems(): - if defaultParams.has_key(key): + if key in defaultParams: if fail_on_error: ret[key] = val # try to convert to proper type or raise else: @@ -745,7 +745,7 @@ for k,v in kwargs.items(): name = aliases.get(k) or k key = '%s.%s' % (g, name) - if not rcParams.has_key(key): + if key not in rcParams: raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' % (key, g, name)) Modified: trunk/matplotlib/lib/matplotlib/_pylab_helpers.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -31,7 +31,7 @@ destroy = staticmethod(destroy) def has_fignum(num): - return Gcf.figs.has_key(num) + return num in Gcf.figs has_fignum = staticmethod(has_fignum) def get_all_fig_managers(): Modified: trunk/matplotlib/lib/matplotlib/afm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/afm.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/afm.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -263,7 +263,7 @@ if len(line)==0: continue key = line.split()[0] - if optional.has_key(key): d[key] = optional[key](fh) + if key in optional: d[key] = optional[key](fh) l = ( d['StartKernData'], d['StartComposites'] ) return l Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/artist.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -662,7 +662,7 @@ alias, return 'markerfacecolor or mfc' and for the transform property, which does not, return 'transform' """ - if self.aliasd.has_key(s): + if s in self.aliasd: return '%s or %s' % (s, self.aliasd[s]) else: return s Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -73,17 +73,17 @@ chars = [c for c in fmt] for c in chars: - if mlines.lineStyles.has_key(c): + if c in mlines.lineStyles: if linestyle is not None: raise ValueError( 'Illegal format string "%s"; two linestyle symbols' % fmt) linestyle = c - elif mlines.lineMarkers.has_key(c): + elif c in mlines.lineMarkers: if marker is not None: raise ValueError( 'Illegal format string "%s"; two marker symbols' % fmt) marker = c - elif mcolors.colorConverter.colors.has_key(c): + elif c in mcolors.colorConverter.colors: if color is not None: raise ValueError( 'Illegal format string "%s"; two color symbols' % fmt) @@ -2632,7 +2632,7 @@ #if t.get_clip_on(): t.set_clip_box(self.bbox) - if kwargs.has_key('clip_on'): t.set_clip_box(self.bbox) + if 'clip_on' in kwargs: t.set_clip_box(self.bbox) return t text.__doc__ = cbook.dedent(text.__doc__) % martist.kwdocd Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -234,7 +234,7 @@ return False # finish event propagation? def _get_key(self, event): - if self.keyvald.has_key(event.keyval): + if event.keyval in self.keyvald: key = self.keyvald[event.keyval] elif event.keyval <256: key = chr(event.keyval) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -170,7 +170,7 @@ def _get_key( self, event ): if event.key() < 256: key = event.text().latin1() - elif self.keyvald.has_key( event.key() ): + elif event.key() in self.keyvald.has_key: key = self.keyvald[ event.key() ] else: key = None Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -174,7 +174,7 @@ def _get_key( self, event ): if event.key() < 256: key = str(event.text()) - elif self.keyvald.has_key( event.key() ): + elif event.key() in self.keyvald: key = self.keyvald[ event.key() ] else: key = None Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -297,7 +297,7 @@ def _get_key(self, event): val = event.keysym_num - if self.keyvald.has_key(val): + if val in self.keyvald: key = self.keyvald[val] elif val<256: key = chr(val) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -1141,7 +1141,7 @@ def _get_key(self, evt): keyval = evt.m_keyCode - if self.keyvald.has_key(keyval): + if keyval in self.keyvald: key = self.keyvald[keyval] elif keyval <256: key = chr(keyval) Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -267,9 +267,9 @@ try: dashd = backend_bases.GraphicsContextBase.dashd if cbook.is_string_like(ls): - if dashd.has_key(ls): + if ls in dashd: dashes = [dashd[ls]] - elif cbook.ls_mapper.has_key(ls): + elif ls in cbook.ls_mapper: dashes = [dashd[cbook.ls_mapper[ls]]] else: raise ValueError() @@ -278,9 +278,9 @@ dashes = [] for x in ls: if cbook.is_string_like(x): - if dashd.has_key(x): + if x in dashd: dashes.append(dashd[x]) - elif cbook.ls_mapper.has_key(x): + elif x in cbook.ls_mapper: dashes.append(dashd[cbook.ls_mapper[x]]) else: raise ValueError() Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/cutils.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/config/cutils.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -93,7 +93,7 @@ def _get_data_path(): 'get the path to matplotlib data' - if os.environ.has_key('MATPLOTLIBDATA'): + if 'MATPLOTLIBDATA' in os.environ: path = os.environ['MATPLOTLIBDATA'] if not os.path.isdir(path): raise RuntimeError('Path in environment MATPLOTLIBDATA not a directory') @@ -167,7 +167,7 @@ fname = os.path.join( os.getcwd(), filename) if os.path.exists(fname): return fname - if os.environ.has_key('MATPLOTLIBRC'): + if 'MATPLOTLIBRC' in os.environ: path = os.environ['MATPLOTLIBRC'] if os.path.exists(path): fname = os.path.join(path, filename) Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -461,8 +461,8 @@ def keys(self): return self.tconfig_map.keys() - def has_key(self, val): - return self.tconfig_map.has_key(val) + def __contains__(self, val): + return val in self.tconfig_map def update(self, arg, **kwargs): try: Modified: trunk/matplotlib/lib/matplotlib/config/rcparams.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcparams.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/config/rcparams.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -19,16 +19,16 @@ class RcParams(dict): - + """A dictionary object including validation - + validating functions are defined and associated with rc parameters in rcsetup.py """ - + validate = dict([ (key, converter) for key, (default, converter) in \ defaultParams.iteritems() ]) - + def __setitem__(self, key, val): try: if key in _deprecated_map.keys(): @@ -89,7 +89,7 @@ verbose.set_fileo(ret['verbose.fileo']) for key, (val, line, cnt) in rc_temp.iteritems(): - if defaultParams.has_key(key): + if key in defaultParams: if fail_on_error: ret[key] = val # try to convert to proper type or raise else: @@ -109,7 +109,7 @@ ret['datapath'] = get_data_path() verbose.report('loaded rc file %s'%fname) - + return ret @@ -183,7 +183,7 @@ for k,v in kwargs.items(): name = aliases.get(k) or k key = '%s.%s' % (g, name) - if not rcParams.has_key(key): + if key not in rcParams: raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' % (key, g, name)) Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -591,7 +591,7 @@ key = self._make_key(*args, **kwargs) - if self._seen.has_key(key): + if key in self._seen: ax = self._seen[key] self.sca(ax) return ax @@ -652,7 +652,7 @@ """ key = self._make_key(*args, **kwargs) - if self._seen.has_key(key): + if key in self._seen: ax = self._seen[key] self.sca(ax) return ax @@ -951,7 +951,7 @@ """ for key in ('dpi', 'facecolor', 'edgecolor'): - if not kwargs.has_key(key): + if key not in kwargs: kwargs[key] = rcParams['savefig.%s'%key] transparent = kwargs.pop('transparent', False) Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -505,7 +505,7 @@ for fpath in fontfiles: verbose.report('createFontDict: %s' % (fpath), 'debug') fname = os.path.split(fpath)[1] - if seen.has_key(fname): continue + if fname in seen: continue else: seen[fname] = 1 if fontext == 'afm': try: @@ -552,33 +552,33 @@ for j in range(100, 1000, 100): font[j] = temp[wgt] - if temp.has_key(400): + if 400 in temp: for j in range(100, 1000, 100): font[j] = temp[400] - if temp.has_key(500): - if temp.has_key(400): + if 500 in temp: + if 400 in temp: for j in range(500, 1000, 100): font[j] = temp[500] else: for j in range(100, 1000, 100): font[j] = temp[500] - if temp.has_key(300): + if 300 in temp: for j in [100, 200, 300]: font[j] = temp[300] - if temp.has_key(200): - if temp.has_key(300): + if 200 in temp: + if 300 in temp: for j in [100, 200]: font[j] = temp[200] else: for j in [100, 200, 300]: font[j] = temp[200] - if temp.has_key(800): + if 800 in temp: for j in [600, 700, 800, 900]: font[j] = temp[800] - if temp.has_key(700): - if temp.has_key(800): + if 700 in temp: + if 800 in temp: for j in [600, 700]: font[j] = temp[700] else: @@ -872,7 +872,7 @@ # Create list of font paths for pathname in ['TTFPATH', 'AFMPATH']: - if os.environ.has_key(pathname): + if pathname in os.environ: ttfpath = os.environ[pathname] if ttfpath.find(';') >= 0: #win32 style paths.extend(ttfpath.split(';')) @@ -983,50 +983,50 @@ fname = None font = fontdict - if font.has_key(name): + if name in font: font = font[name] else: verbose.report('\tfindfont failed %(name)s'%locals(), 'debug') return None - if font.has_key(style): + if style in font: font = font[style] - elif style == 'italic' and font.has_key('oblique'): + elif style == 'italic' and 'oblique' in font: font = font['oblique'] - elif style == 'oblique' and font.has_key('italic'): + elif style == 'oblique' and 'italic' in font: font = font['italic'] else: verbose.report('\tfindfont failed %(name)s, %(style)s'%locals(), 'debug') return None - if font.has_key(variant): + if variant in font: font = font[variant] else: verbose.report('\tfindfont failed %(name)s, %(style)s, %(variant)s'%locals(), 'debug') return None - if not font.has_key(weight): + if weight in font: setWeights(font) - if not font.has_key(weight): + if weight not in font: return None font = font[weight] - if font.has_key(stretch): + if stretch in font: stretch_font = font[stretch] - if stretch_font.has_key('scalable'): + if 'scalable' in stretch_font: fname = stretch_font['scalable'] - elif stretch_font.has_key(size): + elif size in stretch_font: fname = stretch_font[size] if fname is None: for val in font.values(): - if val.has_key('scalable'): + if 'scalable' in val: fname = val['scalable'] break if fname is None: for val in font.values(): - if val.has_key(size): + if size in val: fname = val[size] break Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -334,7 +334,7 @@ """ if s is None: s = rcParams['image.interpolation'] s = s.lower() - if not self._interpd.has_key(s): + if s not in self._interpd: raise ValueError('Illegal interpolation string') self._interpolation = s Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -148,7 +148,7 @@ if not self.isaxes and loc in [0,'best']: loc = 'upper right' if is_string_like(loc): - if not self.codes.has_key(loc): + if loc not in self.codes: if self.isaxes: warnings.warn('Unrecognized location "%s". Falling back on "best"; ' 'valid locations are\n\t%s\n' Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -603,7 +603,7 @@ linestyle = '-' if linestyle not in self._lineStyles: - if ls_mapper.has_key(linestyle): + if linestyle in ls_mapper: linestyle = ls_mapper[linestyle] else: verbose.report('Unrecognized line style %s, %s' % Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -711,7 +711,7 @@ def _get_glyph(self, fontname, font_class, sym, fontsize): symbol_name = None - if fontname in self.fontmap and latex_to_bakoma.has_key(sym): + if fontname in self.fontmap and sym in latex_to_bakoma: basename, num = latex_to_bakoma[sym] slanted = (basename == "cmmi10") or sym in self._slanted_symbols try: @@ -1064,7 +1064,7 @@ found_symbol = False - if latex_to_standard.has_key(sym): + if sym in latex_to_standard: fontname, num = latex_to_standard[sym] glyph = chr(num) found_symbol = True Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -1004,7 +1004,7 @@ %(Patch)s """ - if kwargs.has_key('resolution'): + if 'resolution' in kwargs: import warnings warnings.warn('Circle is now scale free. Use CirclePolygon instead!', DeprecationWarning) kwargs.pop('resolution') Modified: trunk/matplotlib/lib/matplotlib/scale.py =================================================================== --- trunk/matplotlib/lib/matplotlib/scale.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/scale.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -330,7 +330,7 @@ if scale is None: scale = 'linear' - if not _scale_mapping.has_key(scale): + if scale not in _scale_mapping: raise ValueError("Unknown scale type '%s'" % scale) return _scale_mapping[scale](axis, **kwargs) Modified: trunk/matplotlib/lib/matplotlib/table.py =================================================================== --- trunk/matplotlib/lib/matplotlib/table.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/table.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -181,7 +181,7 @@ Artist.__init__(self) - if is_string_like(loc) and not self.codes.has_key(loc): + if is_string_like(loc) and loc not in self.codes: warnings.warn('Unrecognized location %s. Falling back on bottom; valid locations are\n%s\t' %(loc, '\n\t'.join(self.codes.keys()))) loc = 'bottom' if is_string_like(loc): loc = self.codes.get(loc, 1) Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/text.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -222,7 +222,7 @@ def _get_layout(self, renderer): key = self.get_prop_tup() - if self.cached.has_key(key): return self.cached[key] + if key in self.cached: return self.cached[key] horizLayout = [] @@ -337,7 +337,7 @@ # rectprops and the bbox will be drawn using bbox_artist # function. This is to keep the backward compatibility. - if rectprops is not None and rectprops.has_key("boxstyle"): + if rectprops is not None and "boxstyle" in rectprops: props = rectprops.copy() boxstyle = props.pop("boxstyle") bbox_transmuter = props.pop("bbox_transmuter", None) Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -745,7 +745,7 @@ if vmax<vmin: vmin, vmax = vmax, vmin - if self.presets.has_key((vmin, vmax)): + if (vmin, vmax) in self.presets: return self.presets[(vmin, vmax)] if self.numticks is None: Modified: trunk/matplotlib/lib/pytz/tzinfo.py =================================================================== --- trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -136,7 +136,7 @@ self._utcoffset, self._dst, self._tzname = self._transition_info[0] _tzinfos[self._transition_info[0]] = self for inf in self._transition_info[1:]: - if not _tzinfos.has_key(inf): + if inf not in _tzinfos: _tzinfos[inf] = self.__class__(inf, _tzinfos) def fromutc(self, dt): Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/setupext.py 2008-10-02 14:28:45 UTC (rev 6143) @@ -70,14 +70,6 @@ import ConfigParser import cStringIO -major, minor1, minor2, s, tmp = sys.version_info -if major<2 or (major==2 and minor1<3): - True = 1 - False = 0 -else: - True = True - False = False - BUILT_PNG = False BUILT_AGG = False BUILT_FT2FONT = False @@ -88,9 +80,9 @@ BUILT_WXAGG = False BUILT_WINDOWING = False BUILT_CONTOUR = False -BUILT_DELAUNAY = False +BUILT_DELAUNAY = False BUILT_NXUTILS = False -BUILT_TRAITS = False +BUILT_TRAITS = False BUILT_CONTOUR = False BUILT_GDK = False BUILT_PATH = False @@ -696,7 +688,7 @@ add_base_flags(module) - if not os.environ.has_key('PKG_CONFIG_PATH'): + if 'PKG_CONFIG_PATH' not in os.environ: # If Gtk+ is installed, pkg-config is required to be installed os.environ['PKG_CONFIG_PATH'] = 'C:\GTK\lib\pkgconfig' Modified: trunk/matplotlib/src/_tkagg.cpp =================================================================== --- trunk/matplotlib/src/_tkagg.cpp 2008-10-02 13:38:50 UTC (rev 6142) +++ trunk/matplotlib/src/_tkagg.cpp 2008-10-02 14:28:45 UTC (rev 6143) @@ -54,7 +54,7 @@ agg::int8u *destbuffer; double l,b,r,t; int destx, desty, destwidth, destheight, deststride; - unsigned long tmp_ptr; + //unsigned long tmp_ptr; long mode; long nval; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-10-04 08:22:04
|
Revision: 6145 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6145&view=rev Author: efiring Date: 2008-10-04 07:16:10 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Change default precision kwarg in spy from None to 0. Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-10-02 15:00:54 UTC (rev 6144) +++ trunk/matplotlib/API_CHANGES 2008-10-04 07:16:10 UTC (rev 6145) @@ -2,6 +2,11 @@ Changes for 0.98.x ================== +* Changed precision kwarg in spy; default is 0, and the string value + 'present' is used for sparse arrays only to show filled locations. + +* EllipseCollection added. + * Added angles kwarg to quiver for more flexible specification of the arrow angles. Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-02 15:00:54 UTC (rev 6144) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-04 07:16:10 UTC (rev 6145) @@ -6648,21 +6648,21 @@ return Pxx, freqs, bins, im - def spy(self, Z, precision=None, marker=None, markersize=None, + def spy(self, Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs): """ call signature:: - spy(Z, precision=None, marker=None, markersize=None, + spy(Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs) ``spy(Z)`` plots the sparsity pattern of the 2-D array *Z*. - If *precision* is *None*, any non-zero value will be plotted; + If *precision* is 0, any non-zero value will be plotted; else, values of :math:`|Z| > precision` will be plotted. For :class:`scipy.sparse.spmatrix` instances, there is a - special case: if *precision* is 0, any value present in + special case: if *precision* is 'present', any value present in the array will be plotted, even if it is identically zero. The array will be plotted as it would be printed, with @@ -6715,12 +6715,15 @@ * ',' pixel """ + if precision is None: + precision = 0 + warnings.DeprecationWarning("Use precision=0 instead of None") + # 2008/10/03 if marker is None and markersize is None and hasattr(Z, 'tocoo'): marker = 's' if marker is None and markersize is None: Z = np.asarray(Z) - if precision is None: mask = Z!=0. - else: mask = np.absolute(Z)>precision + mask = np.absolute(Z)>precision if 'cmap' not in kwargs: kwargs['cmap'] = mcolors.ListedColormap(['w', 'k'], name='binary') @@ -6731,22 +6734,16 @@ else: if hasattr(Z, 'tocoo'): c = Z.tocoo() - if precision == 0: + if precision == 'present': y = c.row x = c.col else: - if precision is None: - nonzero = c.data != 0. - else: - nonzero = np.absolute(c.data) > precision + nonzero = np.absolute(c.data) > precision y = c.row[nonzero] x = c.col[nonzero] else: Z = np.asarray(Z) - if precision is None: - nonzero = Z!=0. - else: - nonzero = np.absolute(Z)>precision + nonzero = np.absolute(Z)>precision y, x = np.nonzero(nonzero) if marker is None: marker = 's' if markersize is None: markersize = 10 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-09-30 11:18:23
|
Revision: 6135 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6135&view=rev Author: jdh2358 Date: 2008-09-30 11:18:10 +0000 (Tue, 30 Sep 2008) Log Message: ----------- removed numerical_methods from imports Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/fill_between.py trunk/matplotlib/examples/pylab_examples/interp_demo.py trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/examples/pylab_examples/fill_between.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_between.py 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2008-09-30 11:18:10 UTC (rev 6135) @@ -1,5 +1,5 @@ #!/usr/bin/env python -import matplotlib.numerical_methods as numerical_methods +import matplotlib.mlab as mlab from pylab import figure, show import numpy as np @@ -13,15 +13,15 @@ ax3 = fig.add_subplot(313) -xs, ys = numerical_methods.poly_between(x, 0, y1) +xs, ys = mlab.poly_between(x, 0, y1) ax.fill(xs, ys) ax.set_ylabel('between y1 and 0') -xs, ys = numerical_methods.poly_between(x, y1, 1) +xs, ys = mlab.poly_between(x, y1, 1) ax2.fill(xs, ys) ax2.set_ylabel('between y1 and 1') -xs, ys = numerical_methods.poly_between(x, y1, y2) +xs, ys = mlab.poly_between(x, y1, y2) ax3.fill(xs, ys) ax3.set_ylabel('between y1 and y2') ax3.set_xlabel('x') Modified: trunk/matplotlib/examples/pylab_examples/interp_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/interp_demo.py 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/examples/pylab_examples/interp_demo.py 2008-09-30 11:18:10 UTC (rev 6135) @@ -1,6 +1,6 @@ from matplotlib.pyplot import figure, show from numpy import pi, sin, linspace -from matplotlib.numerical_methods import stineman_interp +from matplotlib.mlab import stineman_interp x = linspace(0,2*pi,20); y = sin(x); yp = None Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-09-30 11:18:10 UTC (rev 6135) @@ -131,12 +131,9 @@ major, minor1, minor2, s, tmp = sys.version_info _python24 = major>=2 and minor1>=4 -try: - import datetime - import dateutil - import pytz -except ImportError: _havedate = False -else: _havedate = True +# the havedate check was a legacy from old matplotlib which preceeded +# datetime support +_havedate = True #try: # import pkg_resources # pkg_resources is part of setuptools Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-09-30 11:18:10 UTC (rev 6135) @@ -1307,6 +1307,77 @@ ls_mapper = dict(_linestyles) ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles]) +def less_simple_linear_interpolation( x, y, xi, extrap=False ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('less_simple_linear_interpolation has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.less_simple_linear_interpolation( x, y, xi, extrap=extrap ) + +def isvector(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('isvector has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.isvector( x, y, xi, extrap=extrap ) + +def vector_lengths( X, P=2., axis=None ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('vector_lengths has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.vector_lengths( X, P=2., axis=axis ) + +def distances_along_curve( X ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('distances_along_curve has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.distances_along_curve( X ) + +def path_length(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('path_length has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.path_length(X) + +def is_closed_polygon(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('is_closed_polygon has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.is_closed_polygon(X) + +def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('quad2cubic has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y) + + if __name__=='__main__': assert( allequal([1,1,1]) ) assert(not allequal([1,1,0]) ) Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/dates.py 2008-09-30 11:18:10 UTC (rev 6135) @@ -79,6 +79,14 @@ import re, time, math, datetime import pytz + +# compatability for 2008c and older versions +try: + import pytz.zoneinfo +except ImportError: + pytz.zoneinfo = pytz.tzinfo + pytz.zoneinfo.UTC = pytz.UTC + import matplotlib import numpy as np Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-09-29 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/matplotlibrc.template 2008-09-30 11:18:10 UTC (rev 6135) @@ -251,12 +251,12 @@ # The figure subplot parameters. All dimensions are fraction of the # figure width or height -#figure.subplot.left : 0.125 # the left side of the subplots of the figure -#figure.subplot.right : 0.9 # the right side of the subplots of the figure -#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure -#figure.subplot.top : 0.9 # the top of the subplots of the figure -#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots -#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots +#figure.subplot.left : 0.125 # the left side of the subplots of the figure +#figure.subplot.right : 0.9 # the right side of the subplots of the figure +#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure +#figure.subplot.top : 0.9 # the top of the subplots of the figure +#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots +#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots ### IMAGES #image.aspect : equal # equal | auto | a number @@ -272,7 +272,7 @@ ### SAVING FIGURES #path.simplify : False # When True, simplify paths in vector backends, such as PDF, PS and SVG -# the default savefig params can be different for the GUI backends. +# the default savefig params can be different from the display params # Eg, you may want a higher resolution, or to make the figure # background white #savefig.dpi : 100 # figure dots per inch @@ -308,12 +308,12 @@ # Set the verbose flags. This controls how much information # matplotlib gives you at runtime and where it goes. The verbosity # levels are: silent, helpful, debug, debug-annoying. Any level is -# inclusive of all the levels below it. If you setting is debug, +# inclusive of all the levels below it. If your setting is "debug", # you'll get all the debug and helpful messages. When submitting -# problems to the mailing-list, please set verbose to helpful or debug +# problems to the mailing-list, please set verbose to "helpful" or "debug" # and paste the output into your report. # -# The fileo gives the destination for any calls to verbose.report. +# The "fileo" gives the destination for any calls to verbose.report. # These objects can a filename, or a filehandle like sys.stdout. # # You can override the rc default verbosity from the command line by This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-10-05 01:38:42
|
Revision: 6147 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6147&view=rev Author: efiring Date: 2008-10-05 01:38:31 +0000 (Sun, 05 Oct 2008) Log Message: ----------- New legend kwarg: borderpad to replace pad (primary code by Jae-Joon Lee) Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/CHANGELOG 2008-10-05 01:38:31 UTC (rev 6147) @@ -1,3 +1,6 @@ +2008-10-04 Experimental new kwarg borderpad to replace pad in legend, + based on suggestion by Jae-Joon Lee. - EF + 2008-09-27 Allow spy to ignore zero values in sparse arrays, based on patch by Tony Yu. Also fixed plot to handle empty data arrays, and fixed handling of markers in figlegend. - EF Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-10-05 01:38:31 UTC (rev 6147) @@ -85,6 +85,7 @@ numpoints = None, # the number of points in the legend line prop = None, pad = None, # the fractional whitespace inside the legend border + borderpad = None, markerscale = None, # the relative size of legend markers vs. original # the following dimensions are in axes coords labelsep = None, # the vertical space between the legend entries @@ -116,12 +117,15 @@ Artist.__init__(self) - proplist=[numpoints, pad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow] - propnames=['numpoints', 'pad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow'] + proplist=[numpoints, pad, borderpad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow] + propnames=['numpoints', 'pad', 'borderpad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow'] for name, value in safezip(propnames,proplist): if value is None: value=rcParams["legend."+name] setattr(self,name,value) + if pad: + warnings.DeprecationWarning("Use 'borderpad' instead of 'pad'.") + # 2008/10/04 if self.numpoints <= 0: raise ValueError("numpoints must be >= 0; it was %d"% numpoints) if prop is None: @@ -532,8 +536,14 @@ # Set the data for the legend patch bbox = self._get_handle_text_bbox(renderer) - bbox = bbox.expanded(1 + self.pad, 1 + self.pad) + if self.pad: + bbox = bbox.expanded(1 + self.pad, 1 + self.pad) + else: + bbox = bbox.transformed(self.get_transform()) + bbox = bbox.padded(self.borderpad*self.fontsize) + bbox = bbox.inverse_transformed(self.get_transform()) l, b, w, h = bbox.bounds + self.legendPatch.set_bounds(l, b, w, h) ox, oy = 0, 0 # center Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-05 01:38:31 UTC (rev 6147) @@ -416,7 +416,8 @@ 'legend.isaxes' : [True,validate_bool], # this option is internally ignored - it never served any useful purpose 'legend.numpoints' : [2, validate_int], # the number of points in the legend line 'legend.fontsize' : ['large', validate_fontsize], - 'legend.pad' : [0.2, validate_float], # the fractional whitespace inside the legend border + 'legend.pad' : [0, validate_float], # was 0.2, deprecated; the fractional whitespace inside the legend border + 'legend.borderpad' : [0.5, validate_float], # units are fontsize 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original # the following dimensions are in axes coords Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/matplotlibrc.template 2008-10-05 01:38:31 UTC (rev 6147) @@ -233,7 +233,8 @@ #legend.isaxes : True #legend.numpoints : 2 # the number of points in the legend line #legend.fontsize : large -#legend.pad : 0.2 # the fractional whitespace inside the legend border +#legend.pad : 0.0 # deprecated; the fractional whitespace inside the legend border +#legend.borderpad : 0.5 # border whitspace in fontsize units #legend.markerscale : 1.0 # the relative size of legend markers vs. original # the following dimensions are in axes coords #legend.labelsep : 0.010 # the vertical space between the legend entries This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-10-05 04:33:01
|
Revision: 6148 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6148&view=rev Author: efiring Date: 2008-10-05 04:32:52 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Add scilimits kwarg to Axes.ticklabel_format() method Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-05 01:38:31 UTC (rev 6147) +++ trunk/matplotlib/CHANGELOG 2008-10-05 04:32:52 UTC (rev 6148) @@ -1,3 +1,7 @@ +2008-10-04 Added 'scilimits' kwarg to Axes.ticklabel_format() method, + for easy access to the set_powerlimits method of the + major ScalarFormatter. - EF + 2008-10-04 Experimental new kwarg borderpad to replace pad in legend, based on suggestion by Jae-Joon Lee. - EF Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-05 01:38:31 UTC (rev 6147) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-05 04:32:52 UTC (rev 6148) @@ -1639,26 +1639,34 @@ Optional keyword arguments: - ======= ===================================== - Keyword Description - ======= ===================================== - *style* [ 'sci' (or 'scientific') | 'plain' ] - plain turns off scientific notation - *axis* [ 'x' | 'y' | 'both' ] - ======= ===================================== + ============ ===================================== + Keyword Description + ============ ===================================== + *style* [ 'sci' (or 'scientific') | 'plain' ] + plain turns off scientific notation + *scilimits* (m, n), pair of integers; if *style* + is 'sci', scientific notation will + be used for numbers outside the range + 10`-m`:sup: to 10`n`:sup:. + Use (0,0) to include all numbers. + *axis* [ 'x' | 'y' | 'both' ] + ============ ===================================== Only the major ticks are affected. If the method is called when the :class:`~matplotlib.ticker.ScalarFormatter` is not the :class:`~matplotlib.ticker.Formatter` being used, an - :exc:`AttributeError` will be raised with no additional error - message. + :exc:`AttributeError` will be raised. - Additional capabilities and/or friendlier error checking may - be added. - """ style = kwargs.pop('style', '').lower() + scilimits = kwargs.pop('scilimits', None) + if scilimits is not None: + try: + m, n = scilimits + m+n+1 # check that both are numbers + except (ValueError, TypeError): + raise ValueError("scilimits must be a sequence of 2 integers") axis = kwargs.pop('axis', 'both').lower() if style[:3] == 'sci': sb = True @@ -1673,11 +1681,20 @@ sb = None else: raise ValueError, "%s is not a valid style value" - if sb is not None: - if axis == 'both' or axis == 'x': - self.xaxis.major.formatter.set_scientific(sb) - if axis == 'both' or axis == 'y': - self.yaxis.major.formatter.set_scientific(sb) + try: + if sb is not None: + if axis == 'both' or axis == 'x': + self.xaxis.major.formatter.set_scientific(sb) + if axis == 'both' or axis == 'y': + self.yaxis.major.formatter.set_scientific(sb) + if scilimits is not None: + if axis == 'both' or axis == 'x': + self.xaxis.major.formatter.set_powerlimits(scilimits) + if axis == 'both' or axis == 'y': + self.yaxis.major.formatter.set_powerlimits(scilimits) + except AttributeError: + raise AttributeError( + "This method only works with the ScalarFormatter.") def set_axis_off(self): """turn off the axis""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-05 11:28:06
|
Revision: 6150 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6150&view=rev Author: jouni Date: 2008-10-05 10:14:42 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Merged revisions 6149 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r6149 | jouni | 2008-10-05 13:02:16 +0300 (Sun, 05 Oct 2008) | 2 lines Fix problem with AFM files that don't specify the font's full name or family name ........ Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/afm.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6073 + /branches/v0_91_maint:1-6073,6149 Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-10-05 10:02:16 UTC (rev 6149) +++ trunk/matplotlib/API_CHANGES 2008-10-05 10:14:42 UTC (rev 6150) @@ -1,6 +1,10 @@ Changes for 0.98.x ================== + +* AFM.get_fullname() and get_familyname() no longer raise an + exception if the AFM file does not specify these optional attributes, + but returns a guess based on the required FontName attribute. * Changed precision kwarg in spy; default is 0, and the string value 'present' is used for sparse arrays only to show filled locations. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-05 10:02:16 UTC (rev 6149) +++ trunk/matplotlib/CHANGELOG 2008-10-05 10:14:42 UTC (rev 6150) @@ -1,3 +1,6 @@ +2008-10-05 Fix problem with AFM files that don't specify the font's + full name or family name. - JKS + 2008-10-04 Added 'scilimits' kwarg to Axes.ticklabel_format() method, for easy access to the set_powerlimits method of the major ScalarFormatter. - EF Modified: trunk/matplotlib/lib/matplotlib/afm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/afm.py 2008-10-05 10:02:16 UTC (rev 6149) +++ trunk/matplotlib/lib/matplotlib/afm.py 2008-10-05 10:14:42 UTC (rev 6150) @@ -34,7 +34,7 @@ John D. Hunter <jd...@gm...> """ -import sys, os +import sys, os, re from _mathtext_data import uni2type1 #Convert string the a python type @@ -433,12 +433,22 @@ def get_fullname(self): "Return the font full name, eg, 'Times-Roman'" - return self._header['FullName'] + name = self._header.get('FullName') + if name is None: # use FontName as a substitute + name = self._header['FontName'] + return name def get_familyname(self): "Return the font family name, eg, 'Times'" - return self._header['FamilyName'] + name = self._header.get('FamilyName') + if name is not None: + return name + # FamilyName not specified so we'll make a guess + name = self.get_fullname() + extras = r'(?i)([ -](regular|plain|italic|oblique|bold|semibold|light|ultralight|extra|condensed))+$' + return re.sub(extras, '', name) + def get_weight(self): "Return the font weight, eg, 'Bold' or 'Roman'" return self._header['Weight'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-10-08 16:37:20
|
Revision: 6171 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6171&view=rev Author: mdboom Date: 2008-10-08 16:37:15 +0000 (Wed, 08 Oct 2008) Log Message: ----------- Throw exception when there are too many data points. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h =================================================================== --- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 14:38:26 UTC (rev 6170) +++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 16:37:15 UTC (rev 6171) @@ -29,6 +29,7 @@ #ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED #define AGG_RASTERIZER_CELLS_AA_INCLUDED +#include <exception> #include <string.h> #include <math.h> #include "agg_math.h" @@ -183,7 +184,9 @@ { if((m_num_cells & cell_block_mask) == 0) { - if(m_num_blocks >= cell_block_limit) return; + if(m_num_blocks >= cell_block_limit) { + throw "Agg rendering complexity exceeded."; + } allocate_block(); } *m_curr_cell_ptr++ = m_curr_cell; Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2008-10-08 14:38:26 UTC (rev 6170) +++ trunk/matplotlib/src/_backend_agg.cpp 2008-10-08 16:37:15 UTC (rev 6171) @@ -941,7 +941,11 @@ if (snap) gc.isaa = false; - _draw_path(curve, has_clippath, face, gc); + try { + _draw_path(curve, has_clippath, face, gc); + } catch (const char* e) { + throw Py::RuntimeError(e); + } return Py::Object(); } @@ -1175,20 +1179,24 @@ PathListGenerator path_generator(paths); - _draw_path_collection_generic<PathListGenerator, 1, 1> - (master_transform, - cliprect, - clippath, - clippath_trans, - path_generator, - transforms_obj, - offsets_obj, - offset_trans, - facecolors_obj, - edgecolors_obj, - linewidths, - linestyles_obj, - antialiaseds); + try { + _draw_path_collection_generic<PathListGenerator, 1, 1> + (master_transform, + cliprect, + clippath, + clippath_trans, + path_generator, + transforms_obj, + offsets_obj, + offset_trans, + facecolors_obj, + edgecolors_obj, + linewidths, + linestyles_obj, + antialiaseds); + } catch (const char *e) { + throw Py::RuntimeError(e); + } return Py::Object(); } @@ -1310,20 +1318,24 @@ } try { - _draw_path_collection_generic<QuadMeshGenerator, 0, 0> - (master_transform, - cliprect, - clippath, - clippath_trans, - path_generator, - transforms_obj, - offsets_obj, - offset_trans, - facecolors_obj, - edgecolors_obj, - linewidths, - linestyles_obj, - antialiaseds); + try { + _draw_path_collection_generic<QuadMeshGenerator, 0, 0> + (master_transform, + cliprect, + clippath, + clippath_trans, + path_generator, + transforms_obj, + offsets_obj, + offset_trans, + facecolors_obj, + edgecolors_obj, + linewidths, + linestyles_obj, + antialiaseds); + } catch (const char* e) { + throw Py::RuntimeError(e); + } } catch (...) { if (free_edgecolors) Py_XDECREF(edgecolors_obj.ptr()); throw; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-10-09 01:20:07
|
Revision: 6174 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6174&view=rev Author: efiring Date: 2008-10-09 01:19:54 +0000 (Thu, 09 Oct 2008) Log Message: ----------- path simplification for paths with gaps Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/clippedline.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/agg_py_path_iterator.h Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-08 19:53:57 UTC (rev 6173) +++ trunk/matplotlib/CHANGELOG 2008-10-09 01:19:54 UTC (rev 6174) @@ -1,3 +1,5 @@ +2008-10-08 Add path simplification support to paths with gaps. - EF + 2008-10-05 Fix problem with AFM files that don't specify the font's full name or family name. - JKS Modified: trunk/matplotlib/examples/pylab_examples/clippedline.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/clippedline.py 2008-10-08 19:53:57 UTC (rev 6173) +++ trunk/matplotlib/examples/pylab_examples/clippedline.py 2008-10-09 01:19:54 UTC (rev 6174) @@ -19,7 +19,7 @@ def set_data(self, *args, **kwargs): Line2D.set_data(self, *args, **kwargs) - if self._invalid: + if self._invalid: self.recache() self.xorig = np.array(self._x) self.yorig = np.array(self._y) Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008-10-08 19:53:57 UTC (rev 6173) +++ trunk/matplotlib/lib/matplotlib/path.py 2008-10-09 01:19:54 UTC (rev 6174) @@ -109,9 +109,8 @@ assert vertices.ndim == 2 assert vertices.shape[1] == 2 - self.should_simplify = (codes is None and - np.all(np.isfinite(vertices)) and - len(vertices) >= 128) + self.should_simplify = (len(vertices) >= 128 and + (codes is None or np.all(codes <= Path.LINETO))) self.codes = codes self.vertices = vertices Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2008-10-08 19:53:57 UTC (rev 6173) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-10-09 01:19:54 UTC (rev 6174) @@ -137,7 +137,8 @@ double width = 0.0, double height = 0.0) : m_source(&source), m_quantize(quantize), m_simplify(simplify), m_width(width + 1.0), m_height(height + 1.0), m_queue_read(0), m_queue_write(0), - m_moveto(true), m_lastx(0.0), m_lasty(0.0), m_clipped(false), + m_moveto(true), m_after_moveto(false), + m_lastx(0.0), m_lasty(0.0), m_clipped(false), m_do_clipping(width > 0.0 && height > 0.0), m_origdx(0.0), m_origdy(0.0), m_origdNorm2(0.0), m_dnorm2Max(0.0), m_dnorm2Min(0.0), @@ -205,6 +206,7 @@ *y = front.y; #if DEBUG_SIMPLIFY printf((cmd == agg::path_cmd_move_to) ? "|" : "-"); + printf(" 1 %f %f\n", *x, *y); #endif return cmd; } @@ -239,18 +241,40 @@ //if we are starting a new path segment, move to the first point // + init - if (m_moveto) + +#if DEBUG_SIMPLIFY + printf("x, y, code: %f, %f, %d\n", *x, *y, cmd); +#endif + if (m_moveto || cmd == agg::path_cmd_move_to) { + // m_moveto check is not generally needed because + // m_source generates an initial moveto; but it + // is retained for safety in case circumstances + // arise where this is not true. + if (m_origdNorm2 && !m_after_moveto) + { + // m_origdNorm2 is nonzero only if we have a vector; + // the m_after_moveto check ensures we push this + // vector to the queue only once. + _push(x,y); + } + m_after_moveto = true; m_lastx = *x; m_lasty = *y; m_moveto = false; m_origdNorm2 = 0.0; -#if DEBUG_SIMPLIFY - m_pushed++; - printf("|"); -#endif - return agg::path_cmd_move_to; + // A moveto resulting from a nan yields a missing + // line segment, hence a break in the line, just + // like clipping, so we treat it the same way. + m_clipped = true; + if (m_queue_read < m_queue_write) + { + // If we did a push, empty the queue now. + break; + } + continue; } + m_after_moveto = false; // Don't render line segments less than one pixel long if (fabs(*x - m_lastx) < 1.0 && fabs(*y - m_lasty) < 1.0) @@ -295,7 +319,7 @@ m_origdy = *y - m_lasty; m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy; - //set all the variables to reflect this new orig vecor + //set all the variables to reflect this new orig vector m_dnorm2Max = m_origdNorm2; m_dnorm2Min = 0.0; m_haveMin = false; @@ -376,7 +400,6 @@ #endif continue; } - //if we get here, then this vector was not similar enough to the //line we are building, so we need to draw that line and start the //next one. @@ -384,46 +407,9 @@ //if the line needs to extend in the opposite direction from the //direction we are drawing in, move back to we start drawing from //back there. - if (m_haveMin) - { - m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY); - } - m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY); - //if we clipped some segments between this line and the next line - //we are starting, we also need to move to the last point. - if (m_clipped) { - m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty); - } - else if (!m_lastMax) - { - //if the last line was not the longest line, then move back to - //the end point of the last line in the sequence. Only do this - //if not clipped, since in that case lastx,lasty is not part of - //the line just drawn. + _push(x, y); - //Would be move_to if not for the artifacts - m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty); - } - - //now reset all the variables to get ready for the next line - m_origdx = *x - m_lastx; - m_origdy = *y - m_lasty; - m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy; - - m_dnorm2Max = m_origdNorm2; - m_dnorm2Min = 0.0; - m_haveMin = false; - m_lastMax = true; - m_lastx = m_maxX = *x; - m_lasty = m_maxY = *y; - m_lastWrittenX = m_minX = m_lastx; - m_lastWrittenY = m_minY = m_lasty; - - m_clipped = false; -#if DEBUG_SIMPLIFY - m_pushed += m_queue_write - m_queue_read; -#endif break; } @@ -453,6 +439,8 @@ *y = front.y; #if DEBUG_SIMPLIFY printf((cmd == agg::path_cmd_move_to) ? "|" : "-"); + printf(" 3 %f %f\n", *x, *y); + #endif return cmd; } @@ -489,6 +477,7 @@ item m_queue[6]; bool m_moveto; + bool m_after_moveto; double m_lastx, m_lasty; bool m_clipped; bool m_do_clipping; @@ -512,6 +501,52 @@ unsigned m_pushed; unsigned m_skipped; #endif + + void _push(double* x, double* y) + { + if (m_haveMin) + { + m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY); + } + m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY); + + //if we clipped some segments between this line and the next line + //we are starting, we also need to move to the last point. + if (m_clipped) { + m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty); + } + else if (!m_lastMax) + { + //if the last line was not the longest line, then move back to + //the end point of the last line in the sequence. Only do this + //if not clipped, since in that case lastx,lasty is not part of + //the line just drawn. + + //Would be move_to if not for the artifacts + m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty); + } + + //now reset all the variables to get ready for the next line + m_origdx = *x - m_lastx; + m_origdy = *y - m_lasty; + m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy; + + m_dnorm2Max = m_origdNorm2; + m_dnorm2Min = 0.0; + m_haveMin = false; + m_lastMax = true; + m_lastx = m_maxX = *x; + m_lasty = m_maxY = *y; + m_lastWrittenX = m_minX = m_lastx; + m_lastWrittenY = m_minY = m_lasty; + + m_clipped = false; +#if DEBUG_SIMPLIFY + m_pushed += m_queue_write - m_queue_read; +#endif + + } + }; #endif // __AGG_PY_PATH_ITERATOR_H__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-10-10 19:43:42
|
Revision: 6178 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6178&view=rev Author: efiring Date: 2008-10-10 19:43:34 +0000 (Fri, 10 Oct 2008) Log Message: ----------- Permit chunking in the backend_agg draw_path() method. This is experimental, and disabled by default; it can be enabled by setting the rcParams['agg.path.chunksize'] before a path is drawn. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-10-10 16:53:27 UTC (rev 6177) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-10-10 19:43:34 UTC (rev 6178) @@ -62,7 +62,7 @@ self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False) if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done', 'debug-annoying') - self.draw_path = self._renderer.draw_path + #self.draw_path = self._renderer.draw_path # see below self.draw_markers = self._renderer.draw_markers self.draw_path_collection = self._renderer.draw_path_collection self.draw_quad_mesh = self._renderer.draw_quad_mesh @@ -76,6 +76,28 @@ if __debug__: verbose.report('RendererAgg.__init__ done', 'debug-annoying') + def draw_path(self, gc, path, transform, rgbFace=None): + nmax = rcParams['agg.path.chunksize'] # here at least for testing + npts = path.vertices.shape[0] + if nmax > 100 and npts > nmax and path.should_simplify: + nch = npy.ceil(npts/float(nmax)) + chsize = int(npy.ceil(npts/nch)) + i0 = npy.arange(0, npts, chsize) + i1 = npy.zeros_like(i0) + i1[:-1] = i0[1:] - 1 + i1[-1] = npts + for ii0, ii1 in zip(i0, i1): + v = path.vertices[ii0:ii1,:] + c = path.codes + if c is not None: + c = c[ii0:ii1] + c[0] = Path.MOVETO # move to end of last chunk + p = Path(v, c) + self._renderer.draw_path(gc, p, transform, rgbFace) + else: + self._renderer.draw_path(gc, path, transform, rgbFace) + + def draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw the math text using matplotlib.mathtext Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-10 16:53:27 UTC (rev 6177) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-10 19:43:34 UTC (rev 6178) @@ -488,7 +488,10 @@ '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' : [False, validate_bool] + 'path.simplify' : [False, validate_bool], + 'agg.path.chunksize' : [0, validate_int] # 0 to disable chunking; + # recommend about 20000 to + # enable. Experimental. } if __name__ == '__main__': Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-10-10 16:53:27 UTC (rev 6177) +++ trunk/matplotlib/matplotlibrc.template 2008-10-10 19:43:34 UTC (rev 6178) @@ -270,6 +270,16 @@ ### CONTOUR PLOTS #contour.negative_linestyle : dashed # dashed | solid +### Agg rendering +### Warning: experimental, 2008/10/10 +#agg.path.chunksize : 0 # 0 to disable; values in the range + # 10000 to 100000 can improve speed slightly + # and prevent an Agg rendering failure + # when plotting very large data sets, + # especially if they are very gappy. + # It may cause minor artifacts, though. + # 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |