You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <md...@us...> - 2007-11-06 21:33:39
|
Revision: 4136 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4136&view=rev Author: mdboom Date: 2007-11-06 13:33:37 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Speed up pcolor_demo.py "benchmark" initialization by a factor of 2. Cache the automatically created path codes by their length. pcolor, quadmesh etc. create lots of polylines of the same length, and there is no need to create a new identical codes array each time. (Definite speed improvement, incredible memory improvement). Change the default behavior to create open paths (which don't result in a memory copy). Fix places that were relying on automatically-created closed paths to create closed paths themselves (and thus avoiding a copy). Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/contour.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -4680,9 +4680,10 @@ xy = npy.concatenate((X1[:,newaxis], Y1[:,newaxis], X2[:,newaxis], Y2[:,newaxis], X3[:,newaxis], Y3[:,newaxis], - X4[:,newaxis], Y4[:,newaxis]), + X4[:,newaxis], Y4[:,newaxis], + X1[:,newaxis], Y1[:,newaxis]), axis=1) - verts = xy.reshape((npoly, 4, 2)) + verts = xy.reshape((npoly, 5, 2)) #verts = zip(zip(X1,Y1),zip(X2,Y2),zip(X3,Y3),zip(X4,Y4)) @@ -4696,6 +4697,7 @@ kwargs.setdefault('edgecolors', edgecolors) kwargs.setdefault('antialiaseds', (0,)) kwargs.setdefault('linewidths', (0.25,)) + kwargs['closed'] = False collection = mcoll.PolyCollection(verts, **kwargs) Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -390,14 +390,15 @@ paths = [] # We could let the Path constructor generate the codes for us, # but this is faster, since we know they'll always be the same - codes = npy.array([Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO]) + codes = npy.array([Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]) for m in xrange(meshHeight): for n in xrange(meshWidth): paths.append(Path( [c[m , n], c[m , n+1], c[m+1, n+1], - c[m+1, n]], + c[m+1, n], + c[m , n]], codes)) self._paths = paths @@ -424,13 +425,14 @@ %(Collection)s """ + self.closed = kwargs.pop("closed", True) Collection.__init__(self,**kwargs) self.set_verts(verts) __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def set_verts(self, verts): '''This allows one to delay initialization of the vertices.''' - self._paths = [mpath.Path(v, closed=True) for v in verts] + self._paths = [mpath.Path(v, closed=self.closed) for v in verts] def get_paths(self): return self._paths @@ -611,7 +613,7 @@ segments = [npy.asarray(seg, npy.float_) for seg in segments] if self._uniform_offsets is not None: segments = self._add_offsets(segments) - self._paths = [mpath.Path(seg, closed=False) for seg in segments] + self._paths = [mpath.Path(seg) for seg in segments] set_verts = set_segments # for compatibility with PolyCollection Modified: branches/transforms/lib/matplotlib/contour.py =================================================================== --- branches/transforms/lib/matplotlib/contour.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/contour.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -360,9 +360,9 @@ if inline: new = self.break_linecontour(linecontour, rotation, lw, ind) if len(new[0]): - paths[segNum] = path.Path(new[0], closed=False) + paths[segNum] = path.Path(new[0]) if len(new[1]): - additions.append(path.Path(new[1], closed=False)) + additions.append(path.Path(new[1])) paths.extend(additions) Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -429,7 +429,7 @@ self._y = self._xy[:, 1] # just a view # Masked arrays are now handled by the Path class itself - self._path = Path(self._xy, closed=False) + self._path = Path(self._xy) self._transformed_path = TransformedPath(self._path, self.get_transform()) @@ -683,7 +683,7 @@ steps[0::2, 0], steps[1::2, 0] = vertices[:, 0], vertices[:-1, 0] steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1] - path = Path(steps, closed=False) + path = Path(steps) self._draw_solid(renderer, gc, path, trans) @@ -694,7 +694,7 @@ steps[::2, 0], steps[1:-1:2, 0] = vertices[:, 0], vertices[1:, 0] steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1] - path = Path(steps, closed=False) + path = Path(steps) self._draw_solid(renderer, gc, path, trans) @@ -708,7 +708,7 @@ steps[-1, 0] = vertices[-1, 0] steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1] - path = Path(steps, closed=False) + path = Path(steps) self._draw_solid(renderer, gc, path, trans) @@ -756,7 +756,7 @@ rgbFace) - _triangle_path = Path([[0.0, 1.0], [-1.0, -1.0], [1.0, -1.0]]) + _triangle_path = Path([[0.0, 1.0], [-1.0, -1.0], [1.0, -1.0], [0.0, 1.0]]) def _draw_triangle_up(self, renderer, gc, path, path_trans): offset = 0.5*renderer.points_to_pixels(self._markersize) transform = Affine2D().scale(offset, offset) @@ -838,7 +838,7 @@ path, path_trans, rgbFace) - _line_marker_path = Path([[0.0, -1.0], [0.0, 1.0]], closed=False) + _line_marker_path = Path([[0.0, -1.0], [0.0, 1.0]]) def _draw_vline(self, renderer, gc, path, path_trans): offset = 0.5*renderer.points_to_pixels(self._markersize) transform = Affine2D().scale(offset) @@ -853,7 +853,7 @@ path, path_trans) - _tickhoriz_path = Path([[0.0, 0.5], [1.0, 0.5]], closed=False) + _tickhoriz_path = Path([[0.0, 0.5], [1.0, 0.5]]) def _draw_tickleft(self, renderer, gc, path, path_trans): offset = renderer.points_to_pixels(self._markersize) marker_transform = Affine2D().scale(-offset, 1.0) @@ -868,7 +868,7 @@ path, path_trans) - _tickvert_path = Path([[-0.5, 0.0], [-0.5, 1.0]], closed=False) + _tickvert_path = Path([[-0.5, 0.0], [-0.5, 1.0]]) def _draw_tickup(self, renderer, gc, path, path_trans): offset = renderer.points_to_pixels(self._markersize) marker_transform = Affine2D().scale(1.0, offset) Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/patches.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -578,7 +578,7 @@ [ 0.0, 0.1 ], [ 0.0, -0.1], [ 0.8, -0.1 ], [ 0.8, -0.3], [ 1.0, 0.0 ], [ 0.8, 0.3], - [ 0.8, 0.1 ] ] ) + [ 0.8, 0.1 ], [ 0.0, 0.1] ] ) def __init__( self, x, y, dx, dy, width=1.0, **kwargs ): """Draws an arrow, starting at (x,y), direction and length @@ -727,8 +727,8 @@ xc1, yc1, xc2, yc2 = self.getpoints(x1, y1, xm, ym, k1) xd1, yd1, xd2, yd2 = self.getpoints(x1, y1, xm, ym, k2) - xs = self.convert_xunits([xb1, xb2, xc2, xd2, x1, xd1, xc1]) - ys = self.convert_yunits([yb1, yb2, yc2, yd2, y1, yd1, yc1]) + xs = self.convert_xunits([xb1, xb2, xc2, xd2, x1, xd1, xc1, xb1]) + ys = self.convert_yunits([yb1, yb2, yc2, yd2, y1, yd1, yc1, yb1]) return Path(zip(xs, ys)) Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-06 20:02:07 UTC (rev 4135) +++ branches/transforms/lib/matplotlib/path.py 2007-11-06 21:33:37 UTC (rev 4136) @@ -5,6 +5,7 @@ """ import math +from weakref import WeakValueDictionary import numpy as npy from matplotlib.numerix import npyma as ma @@ -65,8 +66,11 @@ NUM_VERTICES = [1, 1, 1, 2, 3, 1] code_type = npy.uint8 + + _open_codes_cache = WeakValueDictionary() + _closed_codes_cache = WeakValueDictionary() - def __init__(self, vertices, codes=None, closed=True): + def __init__(self, vertices, codes=None, closed=False): """ Create a new path with the given vertices and codes. @@ -88,25 +92,37 @@ resulting path will be compressed, with MOVETO codes inserted in the correct places to jump over the masked regions. """ - mask = ma.nomask if ma.isMaskedArray(vertices): mask = ma.getmask(vertices) else: vertices = npy.asarray(vertices, npy.float_) - + mask = ma.nomask + if codes is None: - if len(vertices) == 0: - codes = npy.zeros((0, ), self.code_type) - elif closed: - codes = self.LINETO * npy.ones( - vertices.shape[0] + 1, self.code_type) - codes[0] = self.MOVETO - codes[-1] = self.CLOSEPOLY + if closed: + # MGDTODO: Remove me once efficiency concerns are + # taken care of. + warnings.warn(""" +EFFICIENCY CONCERN: Having the Path constructor create a closed +polyline automatically is not always the most efficient way to do +things, since it causes a memory copy of the vertices array. If the +caller can easily close the polygon itself it should do so. +""") + codes = self._closed_codes_cache.get(len(vertices)) + if codes is None: + codes = self.LINETO * npy.ones( + vertices.shape[0] + 1, self.code_type) + codes[0] = self.MOVETO + codes[-1] = self.CLOSEPOLY + self._closed_codes_cache[len(vertices)] = codes vertices = npy.concatenate((vertices, [vertices[0]])) - else: - codes = self.LINETO * npy.ones( - vertices.shape[0], self.code_type) - codes[0] = self.MOVETO + else: + codes = self._open_codes_cache.get(len(vertices)) + if codes is None: + codes = self.LINETO * npy.ones( + vertices.shape[0], self.code_type) + codes[0] = self.MOVETO + self._open_codes_cache[len(vertices)] = codes else: codes = npy.asarray(codes, self.code_type) assert codes.ndim == 1 @@ -222,7 +238,7 @@ """ if cls._unit_rectangle is None: cls._unit_rectangle = \ - Path([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]) + Path([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]]) return cls._unit_rectangle unit_rectangle = classmethod(unit_rectangle) @@ -308,7 +324,7 @@ [-1.0, 0.0]], npy.float_) - codes = cls.CURVE4 * npy.ones((len(vertices))) + codes = cls.CURVE4 * npy.ones(14) codes[0] = cls.MOVETO codes[-1] = cls.CLOSEPOLY This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 20:02:18
|
Revision: 4135 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4135&view=rev Author: mdboom Date: 2007-11-06 12:02:07 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Merged revisions 4059-4134 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4061 | jdh2358 | 2007-10-29 14:52:41 -0400 (Mon, 29 Oct 2007) | 2 lines fixed some examples bugs ........ r4062 | jdh2358 | 2007-10-29 15:00:25 -0400 (Mon, 29 Oct 2007) | 2 lines added cohere demo ........ r4072 | dsdale | 2007-10-31 15:43:54 -0400 (Wed, 31 Oct 2007) | 2 lines added STIX fonts ........ r4073 | dsdale | 2007-10-31 15:53:35 -0400 (Wed, 31 Oct 2007) | 2 lines add STIX license agreement ........ r4081 | efiring | 2007-11-01 03:21:00 -0400 (Thu, 01 Nov 2007) | 2 lines Made contour auto level generation work with log color scale ........ r4087 | dsdale | 2007-11-01 10:17:28 -0400 (Thu, 01 Nov 2007) | 2 lines install fonts/otf to mpl-data ........ r4088 | dsdale | 2007-11-01 10:32:52 -0400 (Thu, 01 Nov 2007) | 2 lines dont enable usetex in arrow_demo.py ........ r4092 | dsdale | 2007-11-01 12:56:33 -0400 (Thu, 01 Nov 2007) | 2 lines rm configtest.py from repository ........ r4093 | dsdale | 2007-11-01 12:57:26 -0400 (Thu, 01 Nov 2007) | 2 lines remove STIXFonts zip file ........ r4094 | dsdale | 2007-11-02 08:55:51 -0400 (Fri, 02 Nov 2007) | 2 lines improved ghostscript version checking ........ r4095 | jdh2358 | 2007-11-02 09:13:40 -0400 (Fri, 02 Nov 2007) | 2 lines added Manuel's contour linestyle patch ........ r4096 | dsdale | 2007-11-02 12:37:37 -0400 (Fri, 02 Nov 2007) | 3 lines commit patch 1599876, fixes to qt4agg backend and qt4 blitting demo. Thanks to Phil Thompson. ........ r4097 | jdh2358 | 2007-11-02 14:45:38 -0400 (Fri, 02 Nov 2007) | 2 lines fix unit changes for errorbar_limits code ........ r4106 | efiring | 2007-11-04 21:36:20 -0500 (Sun, 04 Nov 2007) | 2 lines Added easy access to minor tick properties (Pierre G-M) ........ r4107 | mdboom | 2007-11-05 10:45:00 -0500 (Mon, 05 Nov 2007) | 3 lines First pass at getting STIX fonts to work. Support .otf fonts in font_manager.py ........ r4110 | mdboom | 2007-11-05 12:30:08 -0500 (Mon, 05 Nov 2007) | 2 lines Make STIX fonts work. ........ r4112 | efiring | 2007-11-05 14:49:27 -0500 (Mon, 05 Nov 2007) | 2 lines Minor cleanup; removed old ipython hack. ........ r4113 | efiring | 2007-11-05 14:54:49 -0500 (Mon, 05 Nov 2007) | 2 lines make step_demo use npyma ........ r4114 | efiring | 2007-11-05 15:13:00 -0500 (Mon, 05 Nov 2007) | 2 lines Make safezip accept more args; quadmesh_demo cleanup ........ r4115 | mdboom | 2007-11-05 15:42:23 -0500 (Mon, 05 Nov 2007) | 2 lines Fix rcParams bug. ........ r4126 | mdboom | 2007-11-06 13:32:30 -0500 (Tue, 06 Nov 2007) | 3 lines Prevent errors when using OpenType CFF fonts. This means turning off subsetting on backend_pdf, and raising an exception in backend_ps. ........ r4130 | mdboom | 2007-11-06 14:38:29 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ r4131 | mdboom | 2007-11-06 14:38:57 -0500 (Tue, 06 Nov 2007) | 1 line Removing STIX otf fonts ........ r4132 | mdboom | 2007-11-06 14:39:23 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/examples/animation_blit_qt4.py branches/transforms/examples/arrow_demo.py branches/transforms/examples/backend_driver.py branches/transforms/examples/image_slices_viewer.py branches/transforms/examples/keypress_demo.py branches/transforms/examples/mathtext_examples.py branches/transforms/examples/quadmesh_demo.py branches/transforms/examples/step_demo.py branches/transforms/examples/units/bar_unit_demo.py branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/_mathtext_data.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backends/__init__.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/backends/backend_qt4agg.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/config/checkdep.py branches/transforms/lib/matplotlib/config/cutils.py branches/transforms/lib/matplotlib/config/mplconfig.py branches/transforms/lib/matplotlib/config/rcsetup.py branches/transforms/lib/matplotlib/contour.py branches/transforms/lib/matplotlib/font_manager.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/pyplot.py branches/transforms/lib/matplotlib/rcsetup.py branches/transforms/lib/matplotlib/text.py branches/transforms/matplotlibrc.template branches/transforms/setup.py Added Paths: ----------- branches/transforms/examples/cohere_demo.py branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf branches/transforms/license/LICENSE_STIX Removed Paths: ------------- branches/transforms/lib/matplotlib/config/configtest.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4058 + /trunk/matplotlib:1-4134 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/CHANGELOG 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,3 +1,9 @@ +2007-11-02 Commited Phil Thompson's patch 1599876, fixes to Qt4Agg + backend and qt4 blitting demo - DSD + +2007-10-31 Made log color scale easier to use with contourf; + automatic level generation now works. - EF + 2007-10-29 TRANSFORMS REFACTORING The primary goal of this refactoring was to make it easier @@ -66,7 +72,6 @@ See API_CHANGES for more low-level information about this refactoring. - 2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF Modified: branches/transforms/examples/animation_blit_qt4.py =================================================================== --- branches/transforms/examples/animation_blit_qt4.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/animation_blit_qt4.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -15,10 +15,14 @@ class BlitQT(QtCore.QObject): def __init__(self): - QtCore.QObject.__init__(self, None) - self.ax = p.subplot(111) self.canvas = self.ax.figure.canvas + + # By making this a child of the canvas we make sure that it is + # destroyed first and avoids a possible exception when the user clicks + # on the window's close box. + QtCore.QObject.__init__(self, self.canvas) + self.cnt = 0 # create the initial line @@ -26,9 +30,14 @@ self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2) self.background = None + self.old_size = 0, 0 def timerEvent(self, evt): - if self.background is None: + # See if the size has changed since last time round. + current_size = self.ax.bbox.width(), self.ax.bbox.height() + + if self.old_size != current_size: + self.old_size = current_size self.background = self.canvas.copy_from_bbox(self.ax.bbox) # restore the clean slate background Modified: branches/transforms/examples/arrow_demo.py =================================================================== --- branches/transforms/examples/arrow_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/arrow_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -11,7 +11,6 @@ """ from pylab import * -rc('text', usetex=True) rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \ 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'} numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()]) Modified: branches/transforms/examples/backend_driver.py =================================================================== --- branches/transforms/examples/backend_driver.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/backend_driver.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -32,9 +32,10 @@ 'barh_demo.py', 'color_demo.py', 'colorbar_only.py', + 'cohere_demo.py', 'contour_demo.py', 'contourf_demo.py', - 'csd_demo.py', + 'csd_demo.py', 'custom_ticker1.py', 'customize_rc.py', 'date_demo1.py', Copied: branches/transforms/examples/cohere_demo.py (from rev 4132, trunk/matplotlib/examples/cohere_demo.py) =================================================================== --- branches/transforms/examples/cohere_demo.py (rev 0) +++ branches/transforms/examples/cohere_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -0,0 +1,37 @@ +#!/usr/bin/env python +""" +Compute the coherence of two signals +""" +import numpy as n + +from pylab import figure, show + +dt = 0.01 +t = n.arange(0, 30, dt) +Nt = len(t) +nse1 = n.random.randn(Nt) # white noise 1 +nse2 = n.random.randn(Nt) # white noise 2 +r = n.exp(-t/0.05) + +cnse1 = n.convolve(nse1, r)*dt # colored noise 1 +cnse1 = cnse1[:Nt] +cnse2 = n.convolve(nse2, r)*dt # colored noise 2 +cnse2 = cnse2[:Nt] + +# two signals with a coherent part and a random part +s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1 +s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2 + +fig = figure() +ax = fig.add_subplot(211) +ax.plot(t, s1, 'b-', t, s2, 'g-') +ax.set_xlim(0,5) +ax.set_xlabel('time') +ax.set_ylabel('s1 and s2') + +ax = fig.add_subplot(212) +cxy, f = ax.cohere(s1, s2, 256, 1./dt) + +show() + + Modified: branches/transforms/examples/image_slices_viewer.py =================================================================== --- branches/transforms/examples/image_slices_viewer.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/image_slices_viewer.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -17,7 +17,7 @@ self.update() def onscroll(self, event): - + print event.button if event.button=='up': self.ind = numpy.clip(self.ind+1, 0, self.slices-1) else: Modified: branches/transforms/examples/keypress_demo.py =================================================================== --- branches/transforms/examples/keypress_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/keypress_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,21 +1,23 @@ #!/usr/bin/env python """ Show how to connect to keypress events - -Note, on the wx backend on some platforms (eg linux), you have to -first click on the figure before the keypress events are activated. -If you know how to fix this, please email us! """ -from pylab import * +import numpy as n +from pylab import figure, show def press(event): print 'press', event.key - if event.key=='g': - grid() - draw() + if event.key=='x': + visible = xl.get_visible() + xl.set_visible(not visible) + fig.canvas.draw() -connect('key_press_event', press) +fig = figure() +ax = fig.add_subplot(111) -title('press g to toggle grid') -plot(rand(12), rand(12), 'go') +fig.canvas.mpl_connect('key_press_event', press) + +ax.plot(n.random.rand(12), n.random.rand(12), 'go') +xl = ax.set_xlabel('easy come, easy go') + show() Modified: branches/transforms/examples/mathtext_examples.py =================================================================== --- branches/transforms/examples/mathtext_examples.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/mathtext_examples.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -48,7 +48,8 @@ r'$\mathcal{H} = \int d \tau \left(\epsilon E^2 + \mu H^2\right)$', r'$\widehat{abc}\widetilde{def}$', r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$', - r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$' + r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$', + ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * Modified: branches/transforms/examples/quadmesh_demo.py =================================================================== --- branches/transforms/examples/quadmesh_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/quadmesh_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -2,23 +2,26 @@ """ pcolormesh uses a QuadMesh, a faster generalization of pcolor, but with some restrictions. + +This demo illustrates a bug in quadmesh with masked data. """ -import numpy as nx -from pylab import figure,show +import numpy as npy +from matplotlib.pyplot import figure, show from matplotlib import cm, colors +from matplotlib.numerix import npyma as ma n = 56 -x = nx.linspace(-1.5,1.5,n) -X,Y = nx.meshgrid(x,x); -Qx = nx.cos(Y) - nx.cos(X) -Qz = nx.sin(Y) + nx.sin(X) +x = npy.linspace(-1.5,1.5,n) +X,Y = npy.meshgrid(x,x); +Qx = npy.cos(Y) - npy.cos(X) +Qz = npy.sin(Y) + npy.sin(X) Qx = (Qx + 1.1) -Z = nx.sqrt(X**2 + Y**2)/5; -Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z)) +Z = npy.sqrt(X**2 + Y**2)/5; +Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: -Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z) +Zm = ma.masked_where(npy.fabs(Qz) < 0.5*npy.amax(Qz), Z) fig = figure() Modified: branches/transforms/examples/step_demo.py =================================================================== --- branches/transforms/examples/step_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/step_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,5 +1,6 @@ import numpy as npy -from pylab import * +from matplotlib.numerix import npyma as ma +from matplotlib.pyplot import step, legend, xlim, ylim, show x = npy.arange(1, 7, 0.4) y0 = npy.sin(x) @@ -13,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = npy.ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) +y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) step(x,y, label='masked (pre)') legend() @@ -22,3 +23,4 @@ ylim(-0.5, 4) show() + Modified: branches/transforms/examples/units/bar_unit_demo.py =================================================================== --- branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,15 +4,16 @@ N = 5 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm) -menStd = (20*cm, 30*cm, 32*cm, 10*cm, 20*cm) +menStd = ( 20*cm, 30*cm, 32*cm, 10*cm, 20*cm) fig = figure() ax = fig.add_subplot(111) ind = nx.arange(N) # the x locations for the groups -width = 0.35 # the width of the bars +width = 0.35 # the width of the bars p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd) + womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm) womenStd = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm) p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) Modified: branches/transforms/lib/matplotlib/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -234,12 +234,11 @@ def checkdep_ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] + v = stdout.read()[:-1] vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' float(vtest) return vtest Modified: branches/transforms/lib/matplotlib/_mathtext_data.py =================================================================== --- branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1753,7 +1753,10 @@ uni2type1 = dict([(v,k) for k,v in type12uni.items()]) -tex2uni = {'doteq': 8784, +tex2uni = { +'widehat': 0x0302, +'widetilde': 0x0303, +'doteq': 8784, 'partial': 8706, 'gg': 8811, 'asymp': 8781, @@ -1883,7 +1886,7 @@ 'measeq': 8798, 'upharpoonleft': 8639, 'lq': 8216, -'Upsilon': 978, +'Upsilon': 933, 'subsetneq': 8842, 'greater': 62, 'supsetneq': 8843, @@ -2236,7 +2239,7 @@ 'combiningbreve' : 774, 'combiningoverline' : 772, 'combininggraveaccent' : 768, -'combiningacuteaccent' : 714, +'combiningacuteaccent' : 769, 'combiningdiaeresis' : 776, 'combiningtilde' : 771, 'combiningrightarrowabove' : 8407, Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1638,25 +1638,33 @@ self.xaxis.set_scale(value, **kwargs) self._update_transScale() - def get_xticks(self): + def get_xticks(self, minor=False): 'Return the x ticks as a list of locations' - return self.xaxis.get_ticklocs() + return self.xaxis.get_ticklocs(minor=minor) - def set_xticks(self, ticks): + def set_xticks(self, ticks, minor=False): """ Set the x ticks with list of ticks ACCEPTS: sequence of floats """ - return self.xaxis.set_ticks(ticks) + return self.xaxis.set_ticks(ticks, minor=minor) - def get_xticklabels(self): + def get_xmajorticklabels(self): 'Get the xtick labels as a list of Text instances' - return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels()) + return cbook.silent_list('Text xticklabel', self.xaxis.get_majorticklabels()) - def set_xticklabels(self, labels, fontdict=None, **kwargs): + def get_xminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_minorticklabels()) + + def get_xticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels(minor=minor)) + + def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_XTICKLABELS(labels, fontdict=None, **kwargs) + set_xticklabels(labels, fontdict=None, minor=False, **kwargs) Set the xtick labels with list of strings labels Return a list of axis text instances. @@ -1666,7 +1674,7 @@ ACCEPTS: sequence of strings """ - return self.xaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.xaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_xticklabels.__doc__ = cbook.dedent(set_xticklabels.__doc__) % martist.kwdocd def invert_yaxis(self): @@ -1791,25 +1799,33 @@ self.yaxis.set_scale(value, **kwargs) self._update_transScale() - def get_yticks(self): + def get_yticks(self, minor=False): 'Return the y ticks as a list of locations' - return self.yaxis.get_ticklocs() + return self.yaxis.get_ticklocs(minor=minor) - def set_yticks(self, ticks): + def set_yticks(self, ticks, minor=False): """ Set the y ticks with list of ticks ACCEPTS: sequence of floats """ - return self.yaxis.set_ticks(ticks) + return self.yaxis.set_ticks(ticks, minor=minor) - def get_yticklabels(self): - 'Get the ytick labels as a list of Text instances' - return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels()) + def get_ymajorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_majorticklabels()) - def set_yticklabels(self, labels, fontdict=None, **kwargs): + def get_yminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_minorticklabels()) + + def get_yticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels(minor=minor)) + + def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_YTICKLABELS(labels, fontdict=None, **kwargs) + set_yticklabels(labels, fontdict=None, minor=False, **kwargs) Set the ytick labels with list of strings labels. Return a list of Text instances. @@ -1819,7 +1835,7 @@ ACCEPTS: sequence of strings """ - return self.yaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.yaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_yticklabels.__doc__ = cbook.dedent(set_yticklabels.__doc__) % martist.kwdocd def xaxis_date(self, tz=None): @@ -3314,22 +3330,7 @@ patches = [] - # lets do some conversions now - if self.xaxis is not None: - xconv = self.xaxis.converter - if xconv is not None: - units = self.xaxis.get_units() - left = xconv.convert( left, units ) - width = xconv.convert( width, units ) - if self.yaxis is not None: - yconv = self.yaxis.converter - if yconv is not None : - units = self.yaxis.get_units() - bottom = yconv.convert( bottom, units ) - height = yconv.convert( height, units ) - - if align == 'edge': pass elif align == 'center': @@ -3590,7 +3591,7 @@ texts = [] slices = [] autotexts = [] - for frac, label, expl in zip(x,labels, explode): + for frac, label, expl in cbook.safezip(x,labels, explode): x, y = center theta2 = theta1 + frac thetam = 2*math.pi*0.5*(theta1+theta2) @@ -3717,23 +3718,24 @@ a list of error bar cap lines, the third element is a list of line collections for the horizontal and vertical error ranges """ + self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) if not self._hold: self.cla() - # make sure all the args are iterable arrays - if not iterable(x): x = npy.array([x]) - else: x = npy.asarray(x) + # make sure all the args are iterable; use lists not arrays to preserve units + if not iterable(x): + x = [x] - if not iterable(y): y = npy.array([y]) - else: y = npy.asarray(y) + if not iterable(y): + y = [y] if xerr is not None: - if not iterable(xerr): xerr = npy.array([xerr]) - else: xerr = npy.asarray(xerr) + if not iterable(xerr): + xerr = [xerr]*len(x) if yerr is not None: - if not iterable(yerr): yerr = npy.array([yerr]) - else: yerr = npy.asarray(yerr) + if not iterable(yerr): + yerr = [yerr]*len(y) l0 = None @@ -3749,7 +3751,9 @@ if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] - if not iterable(lolims): lolims = npy.array([lolims]*len(x), bool) + # arrays fine here, they are booleans and hence not units + if not iterable(lolims): + lolims = npy.asarray([lolims]*len(x), bool) else: lolims = npy.asarray(lolims, bool) if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) @@ -3761,6 +3765,18 @@ if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool) else: xuplims = npy.asarray(xuplims, bool) + def xywhere(xs, ys, mask): + """ + return xs[mask], ys[mask] where mask is True but xs and + ys are not arrays + """ + assert len(xs)==len(ys) + assert len(xs)==len(mask) + xs = [thisx for thisx, b in zip(xs, mask) if b] + ys = [thisy for thisy, b in zip(ys, mask) if b] + return xs, ys + + if capsize > 0: plot_kw = { 'ms':2*capsize, @@ -3771,51 +3787,68 @@ plot_kw['mew']=kwargs['mew'] if xerr is not None: - if len(xerr.shape) == 1: - left = x-xerr - right = x+xerr + if iterable(xerr) and len(xerr)==2: + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[0])] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[1])] else: - left = x-xerr[0] - right = x+xerr[1] + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] barcols.append( self.hlines(y, left, right, **lines_kw ) ) if capsize > 0: if xlolims.any(): - caplines.extend( self.plot(left[xlolims], y[xlolims], ls='None', marker=mlines.CARETLEFT, **plot_kw) ) + # can't use numpy logical indexing since left and + # y are lists + leftlo, ylo = xywhere(left, y, xlolims) + + caplines.extend( self.plot(leftlo, ylo, ls='None', marker=mlines.CARETLEFT, **plot_kw) ) xlolims = ~xlolims - caplines.extend( self.plot(left[xlolims], y[xlolims], 'k|', **plot_kw) ) + leftlo, ylo = xywhere(left, y, xlolims) + caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) ) else: caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) if xuplims.any(): - caplines.extend( self.plot(right[xuplims], y[xuplims], ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) + + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) xuplims = ~xuplims - caplines.extend( self.plot(right[xuplims], y[xuplims], 'k|', **plot_kw) ) + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, 'k|', **plot_kw) ) else: caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) if yerr is not None: - if len(yerr.shape) == 1: - lower = y-yerr - upper = y+yerr + if iterable(yerr) and len(yerr)==2: + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[0])] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[1])] else: - lower = y-yerr[0] - upper = y+yerr[1] + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] barcols.append( self.vlines(x, lower, upper, **lines_kw) ) if capsize > 0: if lolims.any(): - caplines.extend( self.plot(x[lolims], lower[lolims], ls='None', marker=mlines.CARETDOWN, **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, ls='None', marker=mlines.CARETDOWN, **plot_kw) ) lolims = ~lolims - caplines.extend( self.plot(x[lolims], lower[lolims], 'k_', **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, lower, 'k_', **plot_kw) ) if uplims.any(): - caplines.extend( self.plot(x[uplims], upper[uplims], ls='None', marker=mlines.CARETUP, **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + + caplines.extend( self.plot(xup, upperup, ls='None', marker=mlines.CARETUP, **plot_kw) ) uplims = ~uplims - caplines.extend( self.plot(x[uplims], upper[uplims], 'k_', **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + caplines.extend( self.plot(xup, upperup, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, upper, 'k_', **plot_kw) ) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axis.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -513,8 +513,8 @@ def get_children(self): children = [self.label] majorticks = self.get_major_ticks() - minorticks = self.get_minor_ticks() - + minorticks = self.get_minor_ticks() + children.extend(majorticks) children.extend(minorticks) return children @@ -669,24 +669,62 @@ 'Return the depth of the axis used by the picker' return self.pickradius - def get_ticklabels(self): - 'Return a list of Text instances for ticklabels' + def get_majorticklabels(self): + 'Return a list of Text instances for the major ticklabels' ticks = self.get_major_ticks() labels1 = [tick.label1 for tick in ticks if tick.label1On] labels2 = [tick.label2 for tick in ticks if tick.label2On] - return silent_list('Text ticklabel', labels1+labels2) + return silent_list('Text major ticklabel', labels1+labels2) - def get_ticklines(self): - 'Return the ticklines lines as a list of Line2D instance' + def get_minorticklabels(self): + 'Return a list of Text instances for the minor ticklabels' + ticks = self.get_minor_ticks() + labels1 = [tick.label1 for tick in ticks if tick.label1On] + labels2 = [tick.label2 for tick in ticks if tick.label2On] + return silent_list('Text minor ticklabel', labels1+labels2) + + def get_ticklabels(self, minor=False): + 'Return a list of Text instances for ticklabels' + if minor: + return self.get_minorticklabels() + return self.get_majorticklabels() + + def get_majorticklines(self): + 'Return the major tick lines as a list of Line2D instances' lines = [] - ticks = self.get_major_ticks() + ticks = self.get_major_ticks() for tick in ticks: lines.append(tick.tick1line) lines.append(tick.tick2line) return silent_list('Line2D ticklines', lines) - def get_ticklocs(self): + def get_minorticklines(self): + 'Return the minor tick lines as a list of Line2D instances' + lines = [] + ticks = self.get_minor_ticks() + for tick in ticks: + lines.append(tick.tick1line) + lines.append(tick.tick2line) + return silent_list('Line2D ticklines', lines) + + def get_ticklines(self, minor=False): + 'Return the tick lines as a list of Line2D instances' + if minor: + return self.get_minorticklines() + return self.get_majorticklines() + + def get_majorticklocs(self): + "Get the major tick locations in data coordinates as a numpy array" + return self.major.locator() + + def get_minorticklocs(self): + "Get the minor tick locations in data coordinates as a numpy array" + return self.minor.locator() + + def get_ticklocs(self, minor=False): "Get the tick locations in data coordinates as a numpy array" + if minor: + return self.minor.locator() return self.major.locator() def _get_tick(self, major): @@ -728,7 +766,6 @@ 'get the tick instances; grow as necessary' if numticks is None: numticks = len(self.get_major_locator()()) - if len(self.majorTicks) < numticks: # update the new tick label properties from the old for i in range(numticks - len(self.majorTicks)): @@ -934,23 +971,30 @@ def set_ticklabels(self, ticklabels, *args, **kwargs): """ Set the text values of the tick labels. Return a list of Text - instances. + instances. Use kwarg minor=True to select minor ticks. ACCEPTS: sequence of strings """ #ticklabels = [str(l) for l in ticklabels] + minor = kwargs.pop('minor', False) + if minor: + self.set_minor_formatter(FixedFormatter(ticklabels)) + ticks = self.get_minor_ticks() + else: + self.set_major_formatter( FixedFormatter(ticklabels) ) + ticks = self.get_major_ticks() self.set_major_formatter( FixedFormatter(ticklabels) ) ret = [] - for i, tick in enumerate(self.get_major_ticks()): + for i, tick in enumerate(ticks): if i<len(ticklabels): tick.label1.set_text(ticklabels[i]) ret.append(tick.label1) tick.label1.update(kwargs) return ret - def set_ticks(self, ticks): + def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks @@ -958,10 +1002,14 @@ """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) - self.set_major_locator( FixedLocator(ticks) ) if len(ticks): self.set_view_interval(min(ticks), max(ticks)) - return self.get_major_ticks(len(ticks)) + if minor: + self.set_minor_locator(FixedLocator(ticks)) + return self.get_minor_ticks(len(ticks)) + else: + self.set_major_locator( FixedLocator(ticks) ) + return self.get_major_ticks(len(ticks)) def _update_label_position(self, bboxes, bboxes2): """ Modified: branches/transforms/lib/matplotlib/backends/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,7 +6,7 @@ 'new_figure_manager', 'backend_version'] interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] + 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GDK', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk @@ -50,7 +50,4 @@ return new_figure_manager, draw_if_interactive, show -# a hack to keep old versions of ipython working with mpl -if 'IPython.Shell' in sys.modules: - new_figure_manager, draw_if_interactive, show = pylab_setup() Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -9,6 +9,7 @@ import re import sys import time +import warnings import zlib import numpy as npy @@ -25,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM import matplotlib.type1font as type1font import matplotlib.dviread as dviread @@ -790,7 +791,8 @@ glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) # Why divided by 3.0 ??? Wish I knew... MGD widths.append((ccode, cvt(glyph.horiAdvance) / 3.0)) - cid_to_gid_map[ccode] = unichr(gind) + if ccode < 65536: + cid_to_gid_map[ccode] = unichr(gind) max_ccode = max(ccode, max_ccode) widths.sort() cid_to_gid_map = cid_to_gid_map[:max_ccode + 1] @@ -880,6 +882,15 @@ 'StemV' : 0 # ??? } + # The font subsetting to a Type 3 font does not work for + # OpenType (.otf) that embed a Postscript CFF font, so avoid that -- + # save as a (non-subsetted) Type 42 font instead. + if is_opentype_cff_font(filename): + fonttype = 42 + warnings.warn(("'%s' can not be subsetted into a Type 3 font. " + + "The entire font will be embedded in the output.") % + os.path.basename(filename)) + if fonttype == 3: return embedTTFType3(font, characters, descriptor) elif fonttype == 42: @@ -1130,10 +1141,6 @@ self.truetype_font_cache = {} self.afm_font_cache = {} self.file.used_characters = self.used_characters = {} - if rcParams['pdf.fonttype'] == 3: - self.encode_string = self.encode_string_type3 - else: - self.encode_string = self.encode_string_type42 self.mathtext_parser = MathTextParser("Pdf") self.image_magnification = dpi/72.0 self.tex_font_map = None @@ -1235,7 +1242,7 @@ # When using Type 3 fonts, we can't use character codes higher # than 255, so we use the "Do" command to render those # instead. - fonttype = rcParams['pdf.fonttype'] + global_fonttype = rcParams['pdf.fonttype'] # Set up a global transformation matrix for the whole math expression a = angle / 180.0 * pi @@ -1248,6 +1255,11 @@ prev_font = None, None oldx, oldy = 0, 0 for ox, oy, fontname, fontsize, num, symbol_name in glyphs: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + if fonttype == 42 or num <= 255: self._setup_textpos(ox, oy, 0, oldx, oldy) oldx, oldy = ox, oy @@ -1255,14 +1267,19 @@ self.file.output(self.file.fontName(fontname), fontsize, Op.selectfont) prev_font = fontname, fontsize - self.file.output(self.encode_string(unichr(num)), Op.show) + self.file.output(self.encode_string(unichr(num), fonttype), Op.show) self.file.output(Op.end_text) # If using Type 3 fonts, render all of the two-byte characters # as XObjects using the 'Do' command. - if fonttype == 3: + if global_fonttype == 3: for ox, oy, fontname, fontsize, num, symbol_name in glyphs: - if num > 255: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + + if fonttype == 3 and num > 255: self.file.output(Op.gsave, 0.001 * fontsize, 0, 0, 0.001 * fontsize, @@ -1362,10 +1379,9 @@ self.draw_polygon(boxgc, gc._rgb, ((x1,y1), (x2,y2), (x3,y3), (x4,y4))) - def encode_string_type3(self, s): - return s.encode('cp1252', 'replace') - - def encode_string_type42(self, s): + def encode_string(self, s, fonttype): + if fonttype == 3: + return s.encode('cp1252', 'replace') return s.encode('utf-16be', 'replace') def draw_text(self, gc, x, y, s, prop, angle, ismath=False): @@ -1391,20 +1407,29 @@ font = self._get_font_afm(prop) l, b, w, h = font.get_str_bbox(s) y -= b * fontsize / 1000 + fonttype = 42 else: font = self._get_font_ttf(prop) self.track_characters(font, s) font.set_text(s, 0.0, flags=LOAD_NO_HINTING) y += font.get_descent() / 64.0 + fonttype = rcParams['pdf.fonttype'] + + # We can't subset all OpenType fonts, so switch to Type 42 + # in that case. + if is_opentype_cff_font(font.fname): + fonttype = 42 + def check_simple_method(s): """Determine if we should use the simple or woven method - to output this text, and chunks the string into 1-bit and - 2-bit sections if necessary.""" + to output this text, and chunks the string into 1-byte and + 2-byte sections if necessary.""" use_simple_method = True chunks = [] - if rcParams['pdf.fonttype'] == 3: - if not isinstance(s, str) and len(s) != 0: + + if not rcParams['pdf.use14corefonts']: + if fonttype == 3 and not isinstance(s, str) and len(s) != 0: # Break the string into chunks where each chunk is either # a string of chars <= 255, or a single character > 255. s = unicode(s) @@ -1428,7 +1453,7 @@ prop.get_size_in_points(), Op.selectfont) self._setup_textpos(x, y, angle) - self.file.output(self.encode_string(s), Op.show, Op.end_text) + self.file.output(self.encode_string(s, fonttype), Op.show, Op.end_text) def draw_text_woven(chunks): """Outputs text using the woven method, alternating @@ -1458,7 +1483,7 @@ for chunk_type, chunk in chunks: if mode == 1 and chunk_type == 1: self._setup_textpos(newx, 0, 0, oldx, 0, 0) - self.file.output(self.encode_string(chunk), Op.show) + self.file.output(self.encode_string(chunk, fonttype), Op.show) oldx = newx lastgind = None Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -18,7 +18,7 @@ from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.ttconv import convert_ttf_to_ps from matplotlib.mathtext import MathTextParser @@ -846,7 +846,7 @@ else: self._print_figure(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype) - + def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w', orientation='portrait', isLandscape=False, papertype=None): """ @@ -950,7 +950,15 @@ for c in chars: gind = cmap.get(ord(c)) or 0 glyph_ids.append(gind) - convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) + # The ttf to ps (subsetting) support doesn't work for + # OpenType fonts that are Postscript inside (like the + # STIX fonts). This will simply turn that off to avoid + # errors. + if is_opentype_cff_font(font_filename): + raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.") + else: + fonttype = rcParams['ps.fonttype'] + convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) print >>fh, "end" print >>fh, "%%EndProlog" Modified: branches/transforms/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,8 +6,6 @@ import os, sys import matplotlib -from matplotlib import verbose -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from backend_agg import FigureCanvasAgg @@ -61,7 +59,7 @@ self.drawRect = False self.rect = [] self.replot = True - self.pixmap = QtGui.QPixmap() + self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) @@ -86,26 +84,25 @@ # only replot data when needed if type(self.replot) is bool: # might be a bbox for blitting - if ( self.replot ): - #stringBuffer = str( self.buffer_rgba(0,0) ) - FigureCanvasAgg.draw( self ) + if self.replot: + FigureCanvasAgg.draw(self) - # matplotlib is in rgba byte order. - # qImage wants to put the bytes into argb format and - # is in a 4 byte unsigned int. little endian system is LSB first - # and expects the bytes in reverse order (bgra). - if ( QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian ): - stringBuffer = self.renderer._renderer.tostring_bgra() - else: - stringBuffer = self.renderer._renderer.tostring_argb() - qImage = QtGui.QImage( stringBuffer, self.renderer.width, - self.renderer.height, - QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap( QtCore.QPoint( 0, 0 ), self.pixmap ) + # matplotlib is in rgba byte order. QImage wants to put the bytes + # into argb format and is in a 4 byte unsigned int. Little endian + # system is LSB first and expects the bytes in reverse order + # (bgra). + if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian: + stringBuffer = self.renderer._renderer.tostring_bgra() + else: + stringBuffer = self.renderer._renderer.tostring_argb() + qImage = QtGui.QImage(stringBuffer, self.renderer.width, + self.renderer.height, + QtGui.QImage.Format_ARGB32) + p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage)) + # draw the zoom rectangle to the QPainter - if ( self.drawRect ): + if self.drawRect: p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) ) p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] ) @@ -117,8 +114,8 @@ reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), self.pixmap) + pixmap = QtGui.QPixmap.fromImage(qImage) + p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap) p.end() self.replot = False Modified: branches/transforms/lib/matplotlib/cbook.py =================================================================== --- branches/transforms/lib/matplotlib/cbook.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/cbook.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -558,7 +558,7 @@ # expressions. However, this function accounted for almost 30% of # matplotlib startup time, so it is worthy of optimization at all # costs. - + if not s: # includes case of s is None return '' @@ -577,7 +577,7 @@ if unindent is None: unindent = re.compile("\n\r? {0,%d}" % nshift) _dedent_regex[nshift] = unindent - + result = unindent.sub("\n", s).strip() return result @@ -845,6 +845,15 @@ return mem +_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d' +def safezip(*args): + 'make sure args are equal len before zipping' + Nx = len(args[0]) + for i, arg in enumerate(args[1:]): + if len(arg) != Nx: + raise ValueError(_safezip_msg % (Nx, i+1, len(arg))) + return zip(*args) + class MemoryMonitor: def __init__(self, nmax=20000): self._nmax = nmax Modified: branches/transforms/lib/matplotlib/config/checkdep.py =================================================================== --- branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,28 +4,27 @@ import warnings import distutils.version as version +tex_req = '3.1415' +gs_req = '7.07' +gs_sugg = '8.60' +dvipng_req = '1.5' +pdftops_req = '3.0' + def dvipng(): try: stdin, stdout = os.popen4('dvipng -version') - line = stdout.readlines()[1] - v = line.split()[-1] - float(v) - return v + return stdout.readlines()[1].split()[-1] except (IndexError, ValueError): return None def ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] - vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' - float(vtest) - return vtest + return stdout.read()[:-1] except (IndexError, ValueError): return None @@ -35,9 +34,7 @@ line = stdout.readlines()[0] pattern = '3\.1\d+' match = re.search(pattern, line) - v = match.group(0) - float(v) - return v + return match.group(0) except (IndexError, ValueError): return None @@ -46,9 +43,7 @@ stdin, stdout = os.popen4('pdftops -v') for line in stdout.readlines(): if 'version' in line: - v = line.split()[-1] - float(v) - return v + return line.split()[-1] except (IndexError, ValueError): return None @@ -66,8 +61,6 @@ return False flag = True - gs_req = '7.07' - gs_sugg = '7.07' gs_v = ghostscript() if compare_versions(gs_v, gs_sugg): pass elif compare_versions(gs_v, gs_req): @@ -81,14 +74,13 @@ 'system.') % gs_req) if s == 'xpdf': - pdftops_req = '3.0' pdftops_v = pdftops() if compare_versions(pdftops_v, pdftops_req): pass else: flag = False warnings.warn(('matplotlibrc ps.usedistiller can not be set to ' - 'xpdf unless xpdf-%s or later is installed on your ' - 'system.') % pdftops_req) + 'xpdf unless pdftops-%s or later is installed on ' + 'your system.') % pdftops_req) if flag: return s @@ -99,10 +91,6 @@ if not s: return False - tex_req = '3.1415' - gs_req = '7.07' - gs_sugg = '7.07' - dvipng_req = '1.5' flag = True tex_v = tex() Deleted: branches/transforms/lib/matplotlib/config/configtest.py =================================================================== --- branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,8 +0,0 @@ -from api import rcParams, mplConfig - -print 'loaded your old rcParams["backend"]:', rcParams['backend'] -print 'changing rcParams["backend"] to cairo' -rcParams["backend"] = 'cairo' -print 'mplConfig.backend.use is now :', mplConfig.backend.use -print 'changing rcParams["backend"] to BogusBackend:' -rcParams["backend"] = 'BogusBackend' Modified: branches/transforms/lib/matplotlib/config/cutils.py =================================================================== --- branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -55,8 +55,6 @@ else: raise RuntimeError('please define environment variable $HOME') - - get_home = verbose.wrap('$HOME=%s', _get_home, always=False) def _get_configdir(): @@ -89,9 +87,9 @@ os.mkdir(p) return p + get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False) - def _get_data_path(): 'get the path to matplotlib data' Modified: branches/transforms/lib/matplotlib/config/mplconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -166,7 +166,7 @@ it = T.Trait('serif:oblique' , mplT.FontconfigPatternHandler()) bf = T.Trait('serif:bold' , mplT.FontconfigPatternHandler()) sf = T.Trait('sans' , mplT.FontconfigPatternHandler()) - use_cm = T.true + fontset = T.Trait('cm', 'cm', 'stix', 'custom') fallback_to_cm = T.true class axes(TConfig): @@ -344,7 +344,7 @@ 'mathtext.it' : (self.tconfig.mathtext, 'it'), 'mathtext.bf' : (self.tconfig.mathtext, 'bf'), 'mathtext.sf' : (self.tconfig.mathtext, 'sf'), - 'mathtext.use_cm' : (self.tconfig.mathtext, 'use_cm'), + 'mathtext.fontset' : (self.tconfig.mathtext, 'fontset'), 'mathtext.fallback_to_cm' : (self.tconfig.mathtext, 'fallback_to_cm'), 'image.aspect' : (self.tconfig.image, 'aspect'), Modified: branches/transforms/lib/matplotlib/config/rcsetup.py =================================================================== --- branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -203,6 +203,8 @@ parse_fontconfig_pattern(s) return s +validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'custom']) + validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', ]) @@ -365,7 +367,7 @@ 'mathtext.it' : ['serif:italic', validate_font_properties], 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], - 'mathtext.use_cm' : [True, validate_bool], + 'mathtext.fontset' : ['cm', validate_fontset], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number Modified: branches/transforms/lib/matplotlib/contour.py =================================================================== --- branches/transforms/lib/matplotlib/contour.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/contour.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -395,7 +395,8 @@ self.levels = kwargs.get('levels', None) self.filled = kwargs.get('filled', False) self.linewidths = kwargs.get('linewidths', None) - + self.linestyles = kwargs.get('linestyles', 'solid') + self.alpha = kwargs.get('alpha', 1.0) self.origin = kwargs.get('origin', None) self.extent = kwargs.get('extent', None) @@ -406,6 +407,15 @@ self.antialiased = kwargs.get('antialiased', True) self.nchunk = kwargs.get('nchunk', 0) self.locator = kwargs.get('locator', None) + if (isinstance(norm, colors.LogNorm) + or isinstance(self.locator, ticker.LogLocator)): + self.logscale = True + if norm is None: + norm = colors.LogNorm() + if self.extend is not 'neither': + raise ValueError('extend kwarg does not work yet with log scale') + else: + self.logscale = False if self.origin is not None: assert(self.origin in ['lower', 'upper', 'image']) @@ -453,11 +463,13 @@ else: tlinewidths = self._process_linewidths() self.tlinewidths = tlinewidths + tlinestyles = self._process_linestyles() C = _cntr.Cntr(x, y... [truncated message content] |
From: <md...@us...> - 2007-11-06 19:48:44
|
Revision: 4134 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4134&view=rev Author: mdboom Date: 2007-11-06 11:48:40 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Use "from matplotlib.numerix import npyma as ma" Modified Paths: -------------- branches/transforms/lib/matplotlib/image.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/scale.py Modified: branches/transforms/lib/matplotlib/image.py =================================================================== --- branches/transforms/lib/matplotlib/image.py 2007-11-06 19:46:45 UTC (rev 4133) +++ branches/transforms/lib/matplotlib/image.py 2007-11-06 19:48:40 UTC (rev 4134) @@ -7,7 +7,7 @@ import os import numpy as npy -import numerix.ma as ma +from matplotlib.numerix import npyma as ma from matplotlib import rcParams from artist import Artist Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-06 19:46:45 UTC (rev 4133) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-06 19:48:40 UTC (rev 4134) @@ -8,7 +8,7 @@ import numpy as npy -import numerix.ma as ma +from matplotlib.numerix import npyma as ma from matplotlib import verbose import artist from artist import Artist Modified: branches/transforms/lib/matplotlib/scale.py =================================================================== --- branches/transforms/lib/matplotlib/scale.py 2007-11-06 19:46:45 UTC (rev 4133) +++ branches/transforms/lib/matplotlib/scale.py 2007-11-06 19:48:40 UTC (rev 4134) @@ -1,5 +1,5 @@ import numpy as npy -from numpy import ma +from matplotlib.numerix import npyma as ma from ticker import NullFormatter, ScalarFormatter, LogFormatterMathtext from ticker import NullLocator, LogLocator, AutoLocator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 19:46:51
|
Revision: 4133 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4133&view=rev Author: mdboom Date: 2007-11-06 11:46:45 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Updated docstring to reflect current reality. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_agg.py Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-06 19:39:23 UTC (rev 4132) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-06 19:46:45 UTC (rev 4133) @@ -18,55 +18,9 @@ * allow save to file handle - * allow load from png - * integrate screen dpi w/ ppi and text INSTALLING - - REQUIREMENTs - - python2.2+ - Numeric 22+ - agg2 (see below) - freetype 2 - libpng - libz - - Install AGG2 (cut and paste below into xterm should work) - - wget http://www.antigrain.com/agg2.tar.gz - tar xvfz agg2.tar.gz - cd agg2 - make - - (Optional) if you want to make the examples: - cd examples/X11 - make - - Installing backend_agg - - - Edit setup.py: change aggsrc to point to the agg2 src tree and - replace if 0: with if 1: in the backend_agg section - - Then just do the usual thing: python setup.py build - - Please let me know if you encounter build problems, and tell me - platform, gcc version, etc... Currently the paths in setupext.py - assume as linux like filesystem (eg X11 include dir, location of - libttf, etcc) so you may need to tweak these - - Using agg backend - - python somefile.py -dAgg - - or - - import matplotlib - matplotlib.use('Agg') - - """ from __future__ import division import os, sys, weakref This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 19:39:42
|
Revision: 4132 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4132&view=rev Author: mdboom Date: 2007-11-06 11:39:23 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Converted STIX fonts from otf to ttf. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-06 19:38:57 UTC (rev 4131) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-06 19:39:23 UTC (rev 4132) @@ -835,21 +835,21 @@ return [(fontname, sym)] class StixFonts(UnicodeFonts): - _fontmap = { 'rm' : ('STIXGeneral', 'otf'), - 'tt' : ('VeraMono', 'ttf'), - 'it' : ('STIXGeneralItalic', 'otf'), - 'bf' : ('STIXGeneralBol', 'otf'), - 'sf' : ('Vera', 'ttf'), - 'nonunirm' : ('STIXNonUni', 'otf'), - 'nonuniit' : ('STIXNonUniIta', 'otf'), - 'nonunibf' : ('STIXNonUniBol', 'otf'), + _fontmap = { 'rm' : 'STIXGeneral', + 'tt' : 'VeraMono', + 'it' : 'STIXGeneralItalic', + 'bf' : 'STIXGeneralBol', + 'sf' : 'Vera', + 'nonunirm' : 'STIXNonUni', + 'nonuniit' : 'STIXNonUniIta', + 'nonunibf' : 'STIXNonUniBol', - 0 : ('STIXGeneral', 'otf'), - 1 : ('STIXSiz1Sym', 'otf'), - 2 : ('STIXSiz2Sym', 'otf'), - 3 : ('STIXSiz3Sym', 'otf'), - 4 : ('STIXSiz4Sym', 'otf'), - 5 : ('STIXSiz5Sym', 'otf') + 0 : 'STIXGeneral', + 1 : 'STIXSiz1Sym', + 2 : 'STIXSiz2Sym', + 3 : 'STIXSiz3Sym', + 4 : 'STIXSiz4Sym', + 5 : 'STIXSiz5Sym' } fontmap = {} use_cmex = False @@ -858,8 +858,8 @@ def __init__(self, *args, **kwargs): TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): - for key, (name, ext) in self._fontmap.iteritems(): - fullpath = os.path.join(self.basepath, ext, name + "." + ext) + for key, name in self._fontmap.iteritems(): + fullpath = os.path.join(self.basepath, 'ttf', name + ".ttf") self.fontmap[key] = fullpath self.fontmap[name] = fullpath This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 19:39:05
|
Revision: 4131 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4131&view=rev Author: mdboom Date: 2007-11-06 11:38:57 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Removing STIX otf fonts Removed Paths: ------------- trunk/matplotlib/lib/matplotlib/mpl-data/fonts/otf/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 19:38:34
|
Revision: 4130 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4130&view=rev Author: mdboom Date: 2007-11-06 11:38:29 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Converted STIX fonts from otf to ttf. Added Paths: ----------- trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf Copied: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX (from rev 4106, trunk/matplotlib/lib/matplotlib/mpl-data/fonts/otf/LICENSE_STIX) =================================================================== --- trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX (rev 0) +++ trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX 2007-11-06 19:38:29 UTC (rev 4130) @@ -0,0 +1,71 @@ +TERMS AND CONDITIONS + + 1. Permission is hereby granted, free of charge, to any person +obtaining a copy of the STIX Fonts-TM set accompanying this license +(collectively, the "Fonts") and the associated documentation files +(collectively with the Fonts, the "Font Software"), to reproduce and +distribute the Font Software, including the rights to use, copy, merge +and publish copies of the Font Software, and to permit persons to whom +the Font Software is furnished to do so same, subject to the following +terms and conditions (the "License"). + + 2. The following copyright and trademark notice and these Terms and +Conditions shall be included in all copies of one or more of the Font +typefaces and any derivative work created as permitted under this +License: + + Copyright (c) 2001-2005 by the STI Pub Companies, consisting of +the American Institute of Physics, the American Chemical Society, the +American Mathematical Society, the American Physical Society, Elsevier, +Inc., and The Institute of Electrical and Electronic Engineers, Inc. +Portions copyright (c) 1998-2003 by MicroPress, Inc. Portions copyright +(c) 1990 by Elsevier, Inc. All rights reserved. STIX Fonts-TM is a +trademark of The Institute of Electrical and Electronics Engineers, Inc. + + 3. You may (a) convert the Fonts from one format to another (e.g., +from TrueType to PostScript), in which case the normal and reasonable +distortion that occurs during such conversion shall be permitted and (b) +embed or include a subset of the Fonts in a document for the purposes of +allowing users to read text in the document that utilizes the Fonts. In +each case, you may use the STIX Fonts-TM mark to designate the resulting +Fonts or subset of the Fonts. + + 4. You may also (a) add glyphs or characters to the Fonts, or modify +the shape of existing glyphs, so long as the base set of glyphs is not +removed and (b) delete glyphs or characters from the Fonts, provided +that the resulting font set is distributed with the following +disclaimer: "This [name] font does not include all the Unicode points +covered in the STIX Fonts-TM set but may include others." In each case, +the name used to denote the resulting font set shall not include the +term "STIX" or any similar term. + + 5. You may charge a fee in connection with the distribution of the +Font Software, provided that no copy of one or more of the individual +Font typefaces that form the STIX Fonts-TM set may be sold by itself. + + 6. THE FONT SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK OR OTHER RIGHT. IN NO EVENT SHALL +MICROPRESS OR ANY OF THE STI PUB COMPANIES BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, INCLUDING, BUT NOT LIMITED TO, ANY GENERAL, +SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM OR OUT OF THE USE OR +INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT +SOFTWARE. + + 7. Except as contained in the notice set forth in Section 2, the +names MicroPress Inc. and STI Pub Companies, as well as the names of the +companies/organizations that compose the STI Pub Companies, shall not be +used in advertising or otherwise to promote the sale, use or other +dealings in the Font Software without the prior written consent of the +respective company or organization. + + 8. This License shall become null and void in the event of any +material breach of the Terms and Conditions herein by licensee. + + 9. A substantial portion of the STIX Fonts set was developed by +MicroPress Inc. for the STI Pub Companies. To obtain additional +mathematical fonts, please contact MicroPress, Inc., 68-30 Harrow +Street, Forest Hills, NY 11375, USA - Phone: (718) 575-1816. + Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 19:22:39
|
Revision: 4129 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4129&view=rev Author: jswhit Date: 2007-11-06 11:22:37 -0800 (Tue, 06 Nov 2007) Log Message: ----------- more comments in _readboundar method Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 18:56:21 UTC (rev 4128) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 19:22:37 UTC (rev 4129) @@ -815,36 +815,53 @@ poly = PolygonShape(zip(lons,lats)) else: continue + # if polygon instersects map projection + # region, process it. if poly.intersects(self._boundarypolyll): try: poly = poly.intersection(self._boundarypolyll) - if hasattr(poly,'geoms'): - geoms = poly.geoms + except: + continue + # create iterable object with geometries + # that intersect map region. + if hasattr(poly,'geoms'): + geoms = poly.geoms + else: + geoms = [poly] + # iterate over geometries in intersection. + for psub in geoms: + # only coastlines are polygons, + # which have a 'boundary' attribute. + # otherwise, use 'coords' attribute + # to extract coordinates. + if name == 'gshhs': + b = npy.asarray(psub.boundary) else: - geoms = [poly] - for psub in geoms: - if name == 'gshhs': - b = npy.asarray(psub.boundary) - else: - b = npy.asarray(psub.coords) - blons = b[:,0]; blats = b[:,1] - bx, by = self(blons, blats) - polygons.append(zip(bx,by)) - polygon_types.append(type) - except: - pass + b = npy.asarray(psub.coords) + blons = b[:,0]; blats = b[:,1] + # transformation from lat/lon to + # map projection coordinates. + bx, by = self(blons, blats) + polygons.append(zip(bx,by)) + polygon_types.append(type) # if map boundary polygon is not valid in lat/lon # coordinates, compute intersection between map # projection region and boundary geometries in map # projection coordinates. else: + # only coastlines are polygons, + # which have a 'boundary' attribute. + # otherwise, use 'coords' attribute + # to extract coordinates. if name == 'gshhs': b = npy.asarray(poly.boundary) else: b = npy.asarray(poly.coords) blons = b[:,0]; blats = b[:,1] - # special case for ortho, compute polygon - # coordinates in stereographic coords. + # transform coordinates from lat/lon + # to map projection coordinates. + # special case for ortho, compute coastline polygon + # vertices in stereographic coords. if name == 'gshhs' and self.projection == 'ortho': bx, by = maptran(blons, blats) else: @@ -854,9 +871,12 @@ # map proj coords, skip this geometry. if sum(mask) <= 1: continue if name == 'gshhs': + # create a polygon object for coastline + # geometry. poly = PolygonShape(zip(bx,by)) else: - # remove parts of geometry that are undefined + # if not a polygon, + # just remove parts of geometry that are undefined # in this map projection. bx = npy.compress(mask, bx) by = npy.compress(mask, by) @@ -867,16 +887,22 @@ polygons.append(zip(bx,by)) polygon_types.append(type) continue + # create a Line object for other geometries. poly = LineShape(zip(bx,by)) + # if polygon instersects map projection + # region, process it. if boundarypolyxy.intersects(poly): try: poly = boundarypolyxy.intersection(poly) except: continue + # create iterable object with geometries + # that intersect map region. if hasattr(poly,'geoms'): geoms = poly.geoms else: geoms = [poly] + # iterate over geometries in intersection. for psub in geoms: if name == 'gshhs': b = npy.asarray(psub.boundary) @@ -894,7 +920,11 @@ self._fulldisk and\ areafrac > 0.99: continue bx = b[:,0]; by = b[:,1] + # inverse transform from stereographic + # to lat/lon. blons, blats = maptran(bx, by, inverse=True) + # forward transform from lat/lon to + # orthographic. bx, by = self(blons, blats) b[:,0] = bx; b[:,1] = by polygons.append(zip(b[:,0],b[:,1])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 18:56:26
|
Revision: 4128 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4128&view=rev Author: jswhit Date: 2007-11-06 10:56:21 -0800 (Tue, 06 Nov 2007) Log Message: ----------- use Shapely, libgeos for processing boundary geometries. Modified Paths: -------------- trunk/toolkits/basemap-testing/Changelog Modified: trunk/toolkits/basemap-testing/Changelog =================================================================== --- trunk/toolkits/basemap-testing/Changelog 2007-11-06 18:50:53 UTC (rev 4127) +++ trunk/toolkits/basemap-testing/Changelog 2007-11-06 18:56:21 UTC (rev 4128) @@ -1,4 +1,12 @@ version 0.9.7 (not yet released) + * use Shapely (http://trac.gispython.org/projects/PCL/wiki/Shapely) + to find geometries that are within map projection region. + This speeds up instance creation for small map regions and + high resolution coastlines. Boundary datasets now in binary + format (I/O handled by Shapely). Requires geos C++ lib + (http://geos.refractions.net/) and Shapely, which is a ctypes + interface to libgeos. + * remove all numerix imports. * fix rotate_vector so it works in S. Hem and for non-orthogonal grids. Support for masked velocity vectors also added. (EF) * numpification. (EF) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 18:50:55
|
Revision: 4127 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4127&view=rev Author: jswhit Date: 2007-11-06 10:50:53 -0800 (Tue, 06 Nov 2007) Log Message: ----------- refine check for bogus polygons in fulldisk ortho projection. Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 18:32:30 UTC (rev 4126) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 18:50:53 UTC (rev 4127) @@ -887,10 +887,12 @@ # to orthographic coordinates. if self.projection == 'ortho': # if coastline polygon covers more than 99% - # of map region, it's probably bogus, so - # skip it. - if name == 'gshhs' and \ - psub.area/boundarypolyxy.area > 0.99: continue + # of map region for fulldisk projection, + # it's probably bogus, so skip it. + areafrac = psub.area/boundarypolyxy.area + if name == 'gshhs' and\ + self._fulldisk and\ + areafrac > 0.99: continue bx = b[:,0]; by = b[:,1] blons, blats = maptran(bx, by, inverse=True) bx, by = self(blons, blats) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 18:32:32
|
Revision: 4126 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4126&view=rev Author: mdboom Date: 2007-11-06 10:32:30 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Prevent errors when using OpenType CFF fonts. This means turning off subsetting on backend_pdf, and raising an exception in backend_ps. Modified Paths: -------------- trunk/matplotlib/examples/mathtext_examples.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/font_manager.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/examples/mathtext_examples.py =================================================================== --- trunk/matplotlib/examples/mathtext_examples.py 2007-11-06 18:23:13 UTC (rev 4125) +++ trunk/matplotlib/examples/mathtext_examples.py 2007-11-06 18:32:30 UTC (rev 4126) @@ -49,7 +49,7 @@ r'$\widehat{abc}\widetilde{def}$', r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$', r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$', - ur'Generic symbol: $\u23ce \mathrm{\ue0f2}$' + ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-11-06 18:23:13 UTC (rev 4125) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-11-06 18:32:30 UTC (rev 4126) @@ -9,6 +9,7 @@ import re import sys import time +import warnings import zlib import numpy as npy @@ -25,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM import matplotlib.type1font as type1font import matplotlib.dviread as dviread @@ -786,7 +787,8 @@ glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) # Why divided by 3.0 ??? Wish I knew... MGD widths.append((ccode, cvt(glyph.horiAdvance) / 3.0)) - cid_to_gid_map[ccode] = unichr(gind) + if ccode < 65536: + cid_to_gid_map[ccode] = unichr(gind) max_ccode = max(ccode, max_ccode) widths.sort() cid_to_gid_map = cid_to_gid_map[:max_ccode + 1] @@ -876,6 +878,15 @@ 'StemV' : 0 # ??? } + # The font subsetting to a Type 3 font does not work for + # OpenType (.otf) that embed a Postscript CFF font, so avoid that -- + # save as a (non-subsetted) Type 42 font instead. + if is_opentype_cff_font(filename): + fonttype = 42 + warnings.warn(("'%s' can not be subsetted into a Type 3 font. " + + "The entire font will be embedded in the output.") % + os.path.basename(filename)) + if fonttype == 3: return embedTTFType3(font, characters, descriptor) elif fonttype == 42: @@ -1134,10 +1145,6 @@ self.truetype_font_cache = {} self.afm_font_cache = {} self.file.used_characters = self.used_characters = {} - if rcParams['pdf.fonttype'] == 3: - self.encode_string = self.encode_string_type3 - else: - self.encode_string = self.encode_string_type42 self.mathtext_parser = MathTextParser("Pdf") self.image_magnification = dpi/72.0 self.tex_font_map = None @@ -1344,7 +1351,7 @@ # When using Type 3 fonts, we can't use character codes higher # than 255, so we use the "Do" command to render those # instead. - fonttype = rcParams['pdf.fonttype'] + global_fonttype = rcParams['pdf.fonttype'] # Set up a global transformation matrix for the whole math expression a = angle / 180.0 * pi @@ -1357,6 +1364,11 @@ prev_font = None, None oldx, oldy = 0, 0 for ox, oy, fontname, fontsize, num, symbol_name in glyphs: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + if fonttype == 42 or num <= 255: self._setup_textpos(ox, oy, 0, oldx, oldy) oldx, oldy = ox, oy @@ -1364,14 +1376,19 @@ self.file.output(self.file.fontName(fontname), fontsize, Op.selectfont) prev_font = fontname, fontsize - self.file.output(self.encode_string(unichr(num)), Op.show) + self.file.output(self.encode_string(unichr(num), fonttype), Op.show) self.file.output(Op.end_text) # If using Type 3 fonts, render all of the two-byte characters # as XObjects using the 'Do' command. - if fonttype == 3: + if global_fonttype == 3: for ox, oy, fontname, fontsize, num, symbol_name in glyphs: - if num > 255: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + + if fonttype == 3 and num > 255: self.file.output(Op.gsave, 0.001 * fontsize, 0, 0, 0.001 * fontsize, @@ -1471,10 +1488,9 @@ self.draw_polygon(boxgc, gc._rgb, ((x1,y1), (x2,y2), (x3,y3), (x4,y4))) - def encode_string_type3(self, s): - return s.encode('cp1252', 'replace') - - def encode_string_type42(self, s): + def encode_string(self, s, fonttype): + if fonttype == 3: + return s.encode('cp1252', 'replace') return s.encode('utf-16be', 'replace') def draw_text(self, gc, x, y, s, prop, angle, ismath=False): @@ -1500,20 +1516,29 @@ font = self._get_font_afm(prop) l, b, w, h = font.get_str_bbox(s) y -= b * fontsize / 1000 + fonttype = 42 else: font = self._get_font_ttf(prop) self.track_characters(font, s) font.set_text(s, 0.0, flags=LOAD_NO_HINTING) y += font.get_descent() / 64.0 + fonttype = rcParams['pdf.fonttype'] + + # We can't subset all OpenType fonts, so switch to Type 42 + # in that case. + if is_opentype_cff_font(font.fname): + fonttype = 42 + def check_simple_method(s): """Determine if we should use the simple or woven method - to output this text, and chunks the string into 1-bit and - 2-bit sections if necessary.""" + to output this text, and chunks the string into 1-byte and + 2-byte sections if necessary.""" use_simple_method = True chunks = [] - if rcParams['pdf.fonttype'] == 3: - if not isinstance(s, str) and len(s) != 0: + + if not rcParams['pdf.use14corefonts']: + if fonttype == 3 and not isinstance(s, str) and len(s) != 0: # Break the string into chunks where each chunk is either # a string of chars <= 255, or a single character > 255. s = unicode(s) @@ -1537,7 +1562,7 @@ prop.get_size_in_points(), Op.selectfont) self._setup_textpos(x, y, angle) - self.file.output(self.encode_string(s), Op.show, Op.end_text) + self.file.output(self.encode_string(s, fonttype), Op.show, Op.end_text) def draw_text_woven(chunks): """Outputs text using the woven method, alternating @@ -1567,7 +1592,7 @@ for chunk_type, chunk in chunks: if mode == 1 and chunk_type == 1: self._setup_textpos(newx, 0, 0, oldx, 0, 0) - self.file.output(self.encode_string(chunk), Op.show) + self.file.output(self.encode_string(chunk, fonttype), Op.show) oldx = newx lastgind = None Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-11-06 18:23:13 UTC (rev 4125) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-11-06 18:32:30 UTC (rev 4126) @@ -18,7 +18,7 @@ from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.ttconv import convert_ttf_to_ps from matplotlib.mathtext import MathTextParser @@ -1030,7 +1030,7 @@ else: self._print_figure(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype) - + def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w', orientation='portrait', isLandscape=False, papertype=None): """ @@ -1134,7 +1134,15 @@ for c in chars: gind = cmap.get(ord(c)) or 0 glyph_ids.append(gind) - convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) + # The ttf to ps (subsetting) support doesn't work for + # OpenType fonts that are Postscript inside (like the + # STIX fonts). This will simply turn that off to avoid + # errors. + if is_opentype_cff_font(font_filename): + raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.") + else: + fonttype = rcParams['ps.fonttype'] + convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) print >>fh, "end" print >>fh, "%%EndProlog" Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-11-06 18:23:13 UTC (rev 4125) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-11-06 18:32:30 UTC (rev 4126) @@ -1059,6 +1059,25 @@ return self.defaultFont return fname + +_is_opentype_cff_font_cache = {} +def is_opentype_cff_font(filename): + """ + Returns True if the given font is a Postscript Compact Font Format + Font embedded in an OpenType wrapper. + """ + if os.path.splitext(filename)[1].lower() == '.otf': + result = _is_opentype_cff_font_cache.get(filename) + if result is None: + fd = open(filename, 'rb') + tag = fd.read(4) + fd.close() + result = (tag == 'OTTO') + _is_opentype_cff_font_cache[filename] = result + return result + return False + + if USE_FONTCONFIG and sys.platform != 'win32': import re Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-06 18:23:13 UTC (rev 4125) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-06 18:32:30 UTC (rev 4126) @@ -1945,7 +1945,8 @@ ) | Error(r"Expected \hspace{n}")) ).setParseAction(self.customspace).setName('customspace') - symbol =(Regex(ur"([a-zA-Z0-9 +\-*/<>=:,.;!'@()\u0080-\uffff])|(\\[%${}\[\]])") + unicode_range = u"\U00000080-\U0001ffff" + symbol =(Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!'@()%s])|(\\[%%${}\[\]])" % unicode_range) | Combine( bslash + oneOf(tex2uni.keys()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 18:23:15
|
Revision: 4125 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4125&view=rev Author: jswhit Date: 2007-11-06 10:23:13 -0800 (Tue, 06 Nov 2007) Log Message: ----------- docstring cleanup, remove extra Shapely Polygon call. Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 15:50:51 UTC (rev 4124) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 18:23:13 UTC (rev 4125) @@ -792,7 +792,8 @@ # coordinates (this saves time, especially for small map # regions and high-resolution boundary geometries). if not containsPole: - # close Antarctica for cylindrical projections. + # close Antarctica for cylindrical and + # pseudo-cylindrical projections. if name == 'gshhs' and self.projection in ['cyl','merc','mill','moll','robin','sinu']: b = npy.asarray(poly.boundary) lons = b[:,0] @@ -900,7 +901,7 @@ def _getmapboundary(self): """ - define map boundary polygon (in lat/lon coordinates) + create map boundary polygon (in lat/lon and x/y coordinates) """ nx = 100 ny = 100 @@ -994,7 +995,7 @@ lonprev = lon n = n + 1 boundaryll = PolygonShape(zip(lons,lats)) - return PolygonShape(zip(lons,lats)), boundaryxy + return boundaryll, boundaryxy def drawmapboundary(self,color='k',linewidth=1.0,ax=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 15:50:55
|
Revision: 4124 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4124&view=rev Author: mdboom Date: 2007-11-06 07:50:51 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Update docstring to reflect reality. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-06 15:48:22 UTC (rev 4123) +++ branches/transforms/lib/matplotlib/path.py 2007-11-06 15:50:51 UTC (rev 4124) @@ -70,9 +70,11 @@ """ Create a new path with the given vertices and codes. - vertices is an Nx2 numpy float array. + vertices is an Nx2 numpy float array, masked array or Python + sequence. - codes is an N-length numpy array of type Path.code_type. + codes is an N-length numpy array or Python sequence of type + Path.code_type. See the docstring of Path for a description of the various codes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 15:48:47
|
Revision: 4123 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4123&view=rev Author: mdboom Date: 2007-11-06 07:48:22 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Mistake in last commit. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-06 15:37:44 UTC (rev 4122) +++ branches/transforms/lib/matplotlib/path.py 2007-11-06 15:48:22 UTC (rev 4123) @@ -86,9 +86,11 @@ resulting path will be compressed, with MOVETO codes inserted in the correct places to jump over the masked regions. """ - mask = ma.getmask(vertices) - if not mask: - vertices = ma.asarray(vertices, npy.float_) + mask = ma.nomask + if ma.isMaskedArray(vertices): + mask = ma.getmask(vertices) + else: + vertices = npy.asarray(vertices, npy.float_) if codes is None: if len(vertices) == 0: @@ -121,8 +123,6 @@ codes = ma.masked_array(codes, mask=mask1d).compressed() codes = npy.asarray(codes, self.code_type) - vertices = npy.asarray(vertices, npy.float_) - assert vertices.ndim == 2 assert vertices.shape[1] == 2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 15:38:04
|
Revision: 4122 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4122&view=rev Author: mdboom Date: 2007-11-06 07:37:44 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Minor speed improvement (thanks to Eric Firing). Also use matplotlib.numerix.npyma instead of numpy.ma Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py branches/transforms/lib/matplotlib/transforms.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-06 13:14:08 UTC (rev 4121) +++ branches/transforms/lib/matplotlib/path.py 2007-11-06 15:37:44 UTC (rev 4122) @@ -7,7 +7,7 @@ import math import numpy as npy -from numpy import ma as ma +from matplotlib.numerix import npyma as ma from matplotlib._path import point_in_path, get_path_extents, \ point_in_path_collection @@ -86,7 +86,8 @@ resulting path will be compressed, with MOVETO codes inserted in the correct places to jump over the masked regions. """ - if not ma.isMaskedArray(vertices): + mask = ma.getmask(vertices) + if not mask: vertices = ma.asarray(vertices, npy.float_) if codes is None: @@ -112,7 +113,6 @@ # itself), are not expected to deal with masked arrays, so we # must remove them from the array (using compressed), and add # MOVETO commands to the codes array accordingly. - mask = ma.getmask(vertices) if mask is not ma.nomask: mask1d = ma.mask_or(mask[:, 0], mask[:, 1]) vertices = ma.compress(npy.invert(mask1d), vertices, 0) @@ -125,7 +125,6 @@ assert vertices.ndim == 2 assert vertices.shape[1] == 2 - assert codes.ndim == 1 self._codes = codes self._vertices = vertices Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-11-06 13:14:08 UTC (rev 4121) +++ branches/transforms/lib/matplotlib/transforms.py 2007-11-06 15:37:44 UTC (rev 4122) @@ -24,7 +24,7 @@ """ import numpy as npy -from numpy import ma as ma +from matplotlib.numerix import npyma as ma from numpy.linalg import inv from weakref import WeakKeyDictionary This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 13:14:14
|
Revision: 4121 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4121&view=rev Author: jswhit Date: 2007-11-06 05:14:08 -0800 (Tue, 06 Nov 2007) Log Message: ----------- import meshgrid from numpy Modified Paths: -------------- trunk/toolkits/basemap/examples/simpletest_oo.py Modified: trunk/toolkits/basemap/examples/simpletest_oo.py =================================================================== --- trunk/toolkits/basemap/examples/simpletest_oo.py 2007-11-06 13:13:33 UTC (rev 4120) +++ trunk/toolkits/basemap/examples/simpletest_oo.py 2007-11-06 13:14:08 UTC (rev 4121) @@ -7,7 +7,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.toolkits.basemap import Basemap from matplotlib.figure import Figure -from matplotlib.mlab import meshgrid +from numpy import meshgrid import matplotlib.numerix as nx import matplotlib.cm as cm from matplotlib.mlab import load This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 13:13:36
|
Revision: 4120 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4120&view=rev Author: jswhit Date: 2007-11-06 05:13:33 -0800 (Tue, 06 Nov 2007) Log Message: ----------- remove last vestiges of numerix Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 12:54:20 UTC (rev 4119) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-06 13:13:33 UTC (rev 4120) @@ -10,10 +10,8 @@ from matplotlib.lines import Line2D import pyproj, sys, os, math, dbflib from proj import Proj -from matplotlib.numerix import npyma as ma import numpy as npy -from numpy import linspace -from matplotlib.numerix.mlab import squeeze +from numpy import linspace, ma, squeeze from matplotlib.cbook import is_scalar, dedent from shapelib import ShapeFile This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-06 12:54:22
|
Revision: 4119 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4119&view=rev Author: jswhit Date: 2007-11-06 04:54:20 -0800 (Tue, 06 Nov 2007) Log Message: ----------- import meshgrid from numpy Modified Paths: -------------- trunk/toolkits/basemap-testing/examples/simpletest_oo.py Modified: trunk/toolkits/basemap-testing/examples/simpletest_oo.py =================================================================== --- trunk/toolkits/basemap-testing/examples/simpletest_oo.py 2007-11-05 21:07:32 UTC (rev 4118) +++ trunk/toolkits/basemap-testing/examples/simpletest_oo.py 2007-11-06 12:54:20 UTC (rev 4119) @@ -7,7 +7,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.toolkits.basemap import Basemap from matplotlib.figure import Figure -from matplotlib.mlab import meshgrid +from numpy import meshgrid import matplotlib.numerix as nx import matplotlib.cm as cm from matplotlib.mlab import load This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-05 21:07:35
|
Revision: 4118 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4118&view=rev Author: jswhit Date: 2007-11-05 13:07:32 -0800 (Mon, 05 Nov 2007) Log Message: ----------- remove last vestiges of numerix Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 21:02:33 UTC (rev 4117) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 21:07:32 UTC (rev 4118) @@ -10,10 +10,8 @@ from matplotlib.lines import Line2D import pyproj, sys, os, math, dbflib from proj import Proj -from matplotlib.numerix import ma import numpy as npy -from numpy import linspace -from matplotlib.numerix.mlab import squeeze +from numpy import linspace, squeeze, ma from matplotlib.cbook import popd, is_scalar from shapelib import ShapeFile from shapely.geometry import Polygon as PolygonShape @@ -2572,7 +2570,7 @@ points in datain are masked. To avoid this, do the interpolation in two passes, first with order=1 (producing dataout1), then with order=0 (producing dataout2). Then replace all the masked values in dataout1 - with the corresponding elements in dataout2 (using numerix.where). + with the corresponding elements in dataout2 (using numpy.where). This effectively uses nearest neighbor interpolation if any of the four surrounding points in datain are masked, and bilinear interpolation otherwise. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-05 21:02:36
|
Revision: 4117 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4117&view=rev Author: jswhit Date: 2007-11-05 13:02:33 -0800 (Mon, 05 Nov 2007) Log Message: ----------- cleanups in drawmapboundary Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 20:53:49 UTC (rev 4116) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 21:02:33 UTC (rev 4117) @@ -19,7 +19,7 @@ from shapely.geometry import Polygon as PolygonShape from shapely.geometry import LineString as LineShape from shapely.geometry import Point as PointShape -from shapely import wkb, wkt +from shapely import wkb # basemap data files now installed in lib/matplotlib/toolkits/basemap/data basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data']) @@ -1013,9 +1013,6 @@ ax = pylab.gca() elif ax is None and self.ax is not None: ax = self.ax - x = [] - y = [] - dtheta = 0.01 if self.projection == 'ortho' and self._fulldisk: # circular region. # define a circle patch, add it to axes instance. circle = Circle((self.rmajor,self.rmajor),self.rmajor) @@ -1033,25 +1030,24 @@ ellps.set_linewidth(linewidth) ellps.set_clip_on(False) elif self.projection in ['moll','robin','sinu']: # elliptical region. + nx = 100; ny = 100 + # quasi-elliptical region. + lon_0 = self.projparams['lon_0'] # left side - lats = npy.arange(-89.9,89.9+dtheta,dtheta).tolist() - lons = len(lats)*[self.projparams['lon_0']-179.9] - x,y = self(lons,lats) + lats1 = linspace(-89.9,89.9,ny).tolist() + lons1 = len(lats1)*[lon_0-179.9] # top. - lons = npy.arange(self.projparams['lon_0']-179.9,self.projparams['lon_0']+179+dtheta,dtheta).tolist() - lats = len(lons)*[89.9] - xx,yy = self(lons,lats) - x = x+xx; y = y+yy + lons2 = linspace(lon_0-179.9,lon_0+179.9,nx).tolist() + lats2 = len(lons2)*[89.9] # right side - lats = npy.arange(89.9,-89.9-dtheta,-dtheta).tolist() - lons = len(lats)*[self.projparams['lon_0']+179.9] - xx,yy = self(lons,lats) - x = x+xx; y = y+yy + lats3 = linspace(89.9,-89.9,ny).tolist() + lons3 = len(lats3)*[lon_0+179.9] # bottom. - lons = npy.arange(self.projparams['lon_0']+179.9,self.projparams['lon_0']-180-dtheta,-dtheta).tolist() - lats = len(lons)*[-89.9] - xx,yy = self(lons,lats) - x = x+xx; y = y+yy + lons4 = linspace(lon_0+179.9,lon_0-179.9,nx).tolist() + lats4 = len(lons4)*[-89.9] + lons = npy.array(lons1+lons2+lons3+lons4,npy.float64) + lats = npy.array(lats1+lats2+lats3+lats4,npy.float64) + x, y = self(lons,lats) xy = zip(x,y) poly = Polygon(xy,edgecolor=color,linewidth=linewidth) ax.add_patch(poly) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-05 20:53:51
|
Revision: 4116 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4116&view=rev Author: jswhit Date: 2007-11-05 12:53:49 -0800 (Mon, 05 Nov 2007) Log Message: ----------- some optimizations for orthographic projection Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 20:42:23 UTC (rev 4115) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-05 20:53:49 UTC (rev 4116) @@ -504,6 +504,9 @@ self._fulldisk = False self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + # FIXME: won't work for points exactly on equator?? + if npy.abs(lat_0) < 1.e-2: lat_0 = 1.e-2 + projparams['lat_0'] = lat_0 elif projection == 'geos': if lon_0 is None and satellite_height is None: raise ValueError, 'must specify lon_0 and satellite_height for Geostationary basemap' @@ -758,12 +761,10 @@ # make sure orthographic projection has containsPole=True # we will compute the intersections in stereographic # coordinates, then transform to orthographic. - if self.projection == 'ortho': + if self.projection == 'ortho' and name == 'gshhs': containsPole = True lon_0=self.projparams['lon_0'] lat_0=self.projparams['lat_0'] - # FIXME: won't work for points exactly on equator?? - if npy.abs(lat_0) < 1.e-4: lat_0 = 1.e04 maptran = pyproj.Proj(proj='stere',lon_0=lon_0,lat_0=lat_0) # boundary polygon for orthographic projection # in stereographic coorindates. @@ -845,7 +846,7 @@ blons = b[:,0]; blats = b[:,1] # special case for ortho, compute polygon # coordinates in stereographic coords. - if self.projection == 'ortho': + if name == 'gshhs' and self.projection == 'ortho': bx, by = maptran(blons, blats) else: bx, by = self(blons, blats) @@ -860,6 +861,13 @@ # in this map projection. bx = npy.compress(mask, bx) by = npy.compress(mask, by) + # for orthographic projection, all points + # outside map projection region are eliminated + # with the above step, so we're done. + if self.projection == 'ortho': + polygons.append(zip(bx,by)) + polygon_types.append(type) + continue poly = LineShape(zip(bx,by)) if boundarypolyxy.intersects(poly): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-05 20:42:37
|
Revision: 4115 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4115&view=rev Author: mdboom Date: 2007-11-05 12:42:23 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Fix rcParams bug. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/rcsetup.py Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-11-05 20:13:00 UTC (rev 4114) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-11-05 20:42:23 UTC (rev 4115) @@ -367,7 +367,7 @@ 'mathtext.it' : ['serif:italic', validate_font_properties], 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], - 'mathtext.fontset' : [True, validate_fontset], + 'mathtext.fontset' : ['cm', validate_fontset], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-05 20:13:03
|
Revision: 4114 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4114&view=rev Author: efiring Date: 2007-11-05 12:13:00 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Make safezip accept more args; quadmesh_demo cleanup Modified Paths: -------------- trunk/matplotlib/examples/quadmesh_demo.py trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/examples/quadmesh_demo.py =================================================================== --- trunk/matplotlib/examples/quadmesh_demo.py 2007-11-05 19:54:49 UTC (rev 4113) +++ trunk/matplotlib/examples/quadmesh_demo.py 2007-11-05 20:13:00 UTC (rev 4114) @@ -2,23 +2,26 @@ """ pcolormesh uses a QuadMesh, a faster generalization of pcolor, but with some restrictions. + +This demo illustrates a bug in quadmesh with masked data. """ -import numpy as nx -from pylab import figure,show +import numpy as npy +from matplotlib.pyplot import figure, show from matplotlib import cm, colors +from matplotlib.numerix import npyma as ma n = 56 -x = nx.linspace(-1.5,1.5,n) -X,Y = nx.meshgrid(x,x); -Qx = nx.cos(Y) - nx.cos(X) -Qz = nx.sin(Y) + nx.sin(X) +x = npy.linspace(-1.5,1.5,n) +X,Y = npy.meshgrid(x,x); +Qx = npy.cos(Y) - npy.cos(X) +Qz = npy.sin(Y) + npy.sin(X) Qx = (Qx + 1.1) -Z = nx.sqrt(X**2 + Y**2)/5; -Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z)) +Z = npy.sqrt(X**2 + Y**2)/5; +Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: -Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z) +Zm = ma.masked_where(npy.fabs(Qz) < 0.5*npy.amax(Qz), Z) fig = figure() Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-11-05 19:54:49 UTC (rev 4113) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-11-05 20:13:00 UTC (rev 4114) @@ -557,7 +557,7 @@ # expressions. However, this function accounted for almost 30% of # matplotlib startup time, so it is worthy of optimization at all # costs. - + if not s: # includes case of s is None return '' @@ -576,7 +576,7 @@ if unindent is None: unindent = re.compile("\n\r? {0,%d}" % nshift) _dedent_regex[nshift] = unindent - + result = unindent.sub("\n", s).strip() return result @@ -844,15 +844,15 @@ return mem +_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d' +def safezip(*args): + 'make sure args are equal len before zipping' + Nx = len(args[0]) + for i, arg in enumerate(args[1:]): + if len(arg) != Nx: + raise ValueError(_safezip_msg % (Nx, i+1, len(arg))) + return zip(*args) -def safezip(x, y): - 'make sure x and y are equal len before zipping' - Nx = len(x) - Ny = len(y) - if Nx!=Ny: - raise RuntimeError('x and y must be equal length; found len(x)=%d and len(y)=%d'% - (Nx, Ny)) - return zip(x, y) class MemoryMonitor: def __init__(self, nmax=20000): self._nmax = nmax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-05 19:54:53
|
Revision: 4113 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4113&view=rev Author: efiring Date: 2007-11-05 11:54:49 -0800 (Mon, 05 Nov 2007) Log Message: ----------- make step_demo use npyma Modified Paths: -------------- trunk/matplotlib/examples/step_demo.py Modified: trunk/matplotlib/examples/step_demo.py =================================================================== --- trunk/matplotlib/examples/step_demo.py 2007-11-05 19:49:27 UTC (rev 4112) +++ trunk/matplotlib/examples/step_demo.py 2007-11-05 19:54:49 UTC (rev 4113) @@ -1,5 +1,6 @@ import numpy as npy -from pylab import * +from matplotlib.numerix import npyma as ma +from matplotlib.pyplot import step, legend, xlim, ylim, show x = npy.arange(1, 7, 0.4) y0 = npy.sin(x) @@ -13,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = npy.ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) +y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) step(x,y, label='masked (pre)') legend() @@ -22,3 +23,4 @@ ylim(-0.5, 4) show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-05 19:49:30
|
Revision: 4112 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4112&view=rev Author: efiring Date: 2007-11-05 11:49:27 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Minor cleanup; removed old ipython hack. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/__init__.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/lib/matplotlib/backends/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/__init__.py 2007-11-05 19:47:27 UTC (rev 4111) +++ trunk/matplotlib/lib/matplotlib/backends/__init__.py 2007-11-05 19:49:27 UTC (rev 4112) @@ -6,7 +6,7 @@ 'new_figure_manager', 'backend_version'] interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] + 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GDK', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk @@ -50,7 +50,4 @@ return new_figure_manager, draw_if_interactive, show -# a hack to keep old versions of ipython working with mpl -if 'IPython.Shell' in sys.modules: - new_figure_manager, draw_if_interactive, show = pylab_setup() Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2007-11-05 19:47:27 UTC (rev 4111) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2007-11-05 19:49:27 UTC (rev 4112) @@ -33,20 +33,15 @@ ## Global ## -# a hack to keep old versions of ipython working with mpl after bug -# fix #1209354 -if 'IPython.Shell' in sys.modules: - from matplotlib.backends import new_figure_manager, draw_if_interactive, show -else: - from matplotlib.backends import pylab_setup - new_figure_manager, draw_if_interactive, show = pylab_setup() +from matplotlib.backends import pylab_setup +new_figure_manager, draw_if_interactive, show = pylab_setup() def switch_backend(newbackend): """ Swtich the default backend to newbackend. This feature is EXPERIMENTAL, and is only expected to work switching to an image backend. Eg, if you have a bunch of PS scripts that you want to - run from an interactive ipython session, yuo may want to switch to + run from an interactive ipython session, you may want to switch to the PS backend before running them to avoid having a bunch of GUI windows popup. If you try to interactively switch from one GUI backend to another, you will explode. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |