SF.net SVN: matplotlib: [4391] trunk/matplotlib/lib/matplotlib/backends/ backend_ps.py

2007-11-20 Thread mdboom
Revision: 4391
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4391&view=rev
Author:   mdboom
Date: 2007-11-20 05:29:20 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Fix problem with 0-line width drawing in Postscript.  (Thanks Ben North).

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py  2007-11-20 
13:20:54 UTC (rev 4390)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py  2007-11-20 
13:29:20 UTC (rev 4391)
@@ -947,6 +947,9 @@
 
 if self.linewidth > 0:
 write("stroke\n")
+else:
+write("newpath\n")
+
 if cliprect:
 write("grestore\n")
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib: [4390] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-20 Thread jswhit
Revision: 4390
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4390&view=rev
Author:   jswhit
Date: 2007-11-20 05:20:54 -0800 (Tue, 20 Nov 2007)

Log Message:
---
docstring tweak.

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-20 13:18:22 UTC (rev 4389)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-20 13:20:54 UTC (rev 4390)
@@ -167,8 +167,8 @@
 
  The following parameters are map projection parameters which all default to
  None.  Not all parameters are used by all projections, some are ignored.
- The module variable 'projection_params' lists which parameters apply
- to which projections.
+ The module variable 'projection_params' is a dictionary which 
+ lists which parameters apply to which projections.
 
  lat_ts - latitude of true scale for mercator projection, optional
   for stereographic projection.


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib: [4389] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-20 Thread jswhit
Revision: 4389
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4389&view=rev
Author:   jswhit
Date: 2007-11-20 05:18:22 -0800 (Tue, 20 Nov 2007)

Log Message:
---
added module variable 'projection_params' - a dict containing
the relevant projection parameters for each 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-20 13:14:34 UTC (rev 4388)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-20 13:18:22 UTC (rev 4389)
@@ -53,6 +53,34 @@
 supported_projections.append("'%s' = %s\n" % (_items))
 supported_projections = ''.join(supported_projections)
 
+# projection specific parameters.
+projection_params = {'cyl'  : 'corners only (no width/height)',
+ 'merc' : 'corners plus lat_ts (no width/height)',
+ 'tmerc': 'lon_0,lat_0',
+ 'omerc': 'lon_0,lat_0,lat_1,lat_2,lon_1,lon_2,no 
width/height',
+ 'mill' : 'corners only (no width/height)',
+ 'lcc'  : 'lon_0,lat_0,lat_1,lat_2',
+ 'laea' : 'lon_0,lat_0',
+ 'nplaea'   : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'splaea'   : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'eqdc' : 'lon_0,lat_0,lat_1,lat_2',
+ 'aeqd' : 'lon_0,lat_0',
+ 'npaeqd'   : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'spaeqd'   : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'aea'  : 'lon_0,lat_0,lat_1',
+ 'stere': 'lon_0,lat_0,lat_ts',
+ 'npstere'  : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'spstere'  : 'bounding_lat,lon_0,lat_0,no corners or 
width/height',
+ 'cass' : 'lon_0,lat_0',
+ 'poly' : 'lon_0,lat_0',
+ 'ortho': 'lon_0,lat_0',
+ 'geos' : 'lon_0,lat_0,satellite_height',
+ 'sinu' : 'lon_0,lat_0,no corners or width/height',
+ 'moll' : 'lon_0,lat_0,no corners or width/height',
+ 'robin': 'lon_0,lat_0,no corners or width/height',
+ 'gnom' : 'lon_0,lat_0',
+ }
+
 # The __init__ docstring is pulled out here because it is so long;
 # Having it in the usual place makes it hard to get from the
 # __init__ argument list to the code that uses the arguments.
@@ -65,7 +93,8 @@
 %(supported_projections)s
   Default is 'cyl'.
 
- The map projection region can either be specified by setting these keywords:
+ For most map projections, the map projection region can either be
+ specified by setting these keywords:
 
  llcrnrlon - longitude of lower left hand corner of the desired map domain 
(degrees).
  llcrnrlat - latitude of lower left hand corner of the desired map domain 
(degrees).
@@ -81,9 +110,10 @@
 
  For 'sinu', 'moll', 'npstere', 'spstere', 'nplaea', 'splaea', 'nplaea',
  'splaea', 'npaeqd', 'spaeqd' or 'robin', the values of
- llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat,width and height are ignored (because
- either they are computed internally, or entire globe is always plotted). For 
the
- cylindrical projections ('cyl','merc' and 'mill'), the default is to use
+ llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat,width and height are ignored
+ (because either they are computed internally, or entire globe is
+ always plotted). For the cylindrical projections
+ ('cyl','merc' and 'mill'), the default is to use
  llcrnrlon=-180,llcrnrlat=-90, urcrnrlon=180 and urcrnrlat=90). For all other
  projections except 'ortho' and 'geos', either the lat/lon values of the
  corners or width and height must be specified by the user.
@@ -117,9 +147,10 @@
  in map projection coordinates.  Default False, so parallels and meridians
  can be labelled instead. If parallel or meridian labelling is requested
  (using drawparallels and drawmeridians methods), automatic tick labelling
- will be supressed even is suppress_ticks=False.  Typically, you will
- only want to override the default if you want to label the axes in meters
- using native map projection coordinates.
+ will be supressed even is suppress_ticks=False.  suppress_ticks=False
+ is useful if you want to use your own custom tick formatter, or
+ if you want to let matplotlib label the axes in meters
+ using native map projection coordinates
 
  anchor - determines how map is placed in axes rectangle (passed to
  axes.set_aspect). Default is 'C', which means map is centered.
@@ -136,9 +167,11 @@
 
  The following parameters are map projection parameters which all default to
  None.  Not all parameters are used by all projections, some are ignored.
+ Th

SF.net SVN: matplotlib: [4388] branches/transforms/lib/matplotlib/axes.py

2007-11-20 Thread mdboom
Revision: 4388
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4388&view=rev
Author:   mdboom
Date: 2007-11-20 05:14:34 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Reverting imshow -- these issues are being dealt with by Eric Firing
on the trunk.

Modified Paths:
--
branches/transforms/lib/matplotlib/axes.py

Modified: branches/transforms/lib/matplotlib/axes.py
===
--- branches/transforms/lib/matplotlib/axes.py  2007-11-20 13:13:22 UTC (rev 
4387)
+++ branches/transforms/lib/matplotlib/axes.py  2007-11-20 13:14:34 UTC (rev 
4388)
@@ -4386,9 +4386,7 @@
  plotting z(x,y): imshow, pcolor and relatives, contour
 
 
-def imshow(self, I,
-   X = None,
-   Y = None,
+def imshow(self, X,
cmap = None,
norm = None,
aspect=None,
@@ -4405,24 +4403,18 @@
**kwargs):
 """
 
-IMSHOW(I, X=None, Y=None, cmap=None, norm=None, aspect=None,
-   interpolation=None, alpha=1.0, vmin=None, vmax=None,
-   origin=None, extent=None)
+IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
+   alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
 
-IMSHOW(I) - plot image I to current axes, resampling to scale to axes
-size (I may be numpy array or PIL image)
+IMSHOW(X) - plot image X to current axes, resampling to scale to axes
+size (X may be numarray/Numeric array or PIL image)
 
-IMSHOW(I, X, Y) - plot image I to current axes, with
-  nonuniform X and Y axes.  (I, X and Y may be
-  numarray/Numeric array or PIL image)
-
-IMSHOW(I, X, Y, **kwargs) - Use keyword args to control image
-scaling, colormapping etc. See
-below for details
+IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
+colormapping etc. See below for details
 
 
-Display the image in I to current axes.  I may be a float array, a
-uint8 array or a PIL image. If I is an array, I can have the following
+Display the image in X to current axes.  X may be a float array, a
+uint8 array or a PIL image. If X is an array, X can have the following
 shapes:
 
 MxN: luminance (grayscale, float array only)
@@ -4434,10 +4426,6 @@
 The value for each component of MxNx3 and MxNx4 float arrays should be
 in the range 0.0 to 1.0; MxN float arrays may be normalised.
 
-X and/or Y may be provided to specify a non-uniform image
-grid. Each element of the X or Y arrays is the width or height
-of the corresponding pixel in the given image.
-
 A image.AxesImage instance is returned
 
 The following kwargs are allowed:
@@ -4502,24 +4490,11 @@
 if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
 if aspect is None: aspect = rcParams['image.aspect']
 self.set_aspect(aspect)
-
-if X is None and Y is None:
-im = mimage.AxesImage(self, cmap, norm, interpolation, origin, 
extent,
-  filternorm=filternorm,
-  filterrad=filterrad, **kwargs)
-
-im.set_data(I)
-else:
-if X is None:
-X = npy.arange(I.shape[1])
-if Y is None:
-Y = npy.arange(I.shape[0])
-im = mimage.NonUniformImage(self, cmap=cmap, norm=norm,
-interpolation=interpolation,
-origin=origin, extent=extent,
-filternorm=filternorm,
-filterrad=filterrad, **kwargs)
-im.set_data(X, Y, I)
+im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
+   filternorm=filternorm,
+   filterrad=filterrad, **kwargs)
+
+im.set_data(X)
 im.set_alpha(alpha)
 self._set_artist_props(im)
 im.set_clip_path(self.axesPatch)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib: [4387] trunk/matplotlib/lib/matplotlib/pyparsing.py

2007-11-20 Thread mdboom
Revision: 4387
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4387&view=rev
Author:   mdboom
Date: 2007-11-20 05:13:22 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Speed improvement initializing mathtext parser.

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/pyparsing.py

Modified: trunk/matplotlib/lib/matplotlib/pyparsing.py
===
--- trunk/matplotlib/lib/matplotlib/pyparsing.py2007-11-20 04:09:55 UTC 
(rev 4386)
+++ trunk/matplotlib/lib/matplotlib/pyparsing.py2007-11-20 13:13:22 UTC 
(rev 4387)
@@ -2845,22 +2845,18 @@
 else:
 warnings.warn("Invalid argument to oneOf, expected string or list",
 SyntaxWarning, stacklevel=2)
-
+
+symbols.sort(reverse=True)
 i = 0
 while i < len(symbols)-1:
 cur = symbols[i]
-for j,other in enumerate(symbols[i+1:]):
+for j, other in enumerate(symbols[i+1:]):
 if ( isequal(other, cur) ):
 del symbols[i+j+1]
+else:
 break
-elif ( masks(cur, other) ):
-del symbols[i+j+1]
-symbols.insert(i,other)
-cur = other
-break
-else:
-i += 1
-
+i += 1
+
 if not caseless and useRegex:
 #~ print strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in 
symbols] )
 try:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib: [4392] branches/transforms/src/_backend_agg.cpp

2007-11-20 Thread mdboom
Revision: 4392
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4392&view=rev
Author:   mdboom
Date: 2007-11-20 05:50:04 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Removing trailing whitespace so a merge from trunk will be possible.

Modified Paths:
--
branches/transforms/src/_backend_agg.cpp

Modified: branches/transforms/src/_backend_agg.cpp
===
--- branches/transforms/src/_backend_agg.cpp2007-11-20 13:29:20 UTC (rev 
4391)
+++ branches/transforms/src/_backend_agg.cpp2007-11-20 13:50:04 UTC (rev 
4392)
@@ -50,7 +50,7 @@
  the C++ representation as a std::vector >
  (GCAgg::dash_t)
 */
-void convert_dashes(const Py::Tuple& dashes, double dpi, GCAgg::dash_t& 
dashes_out, 
+void convert_dashes(const Py::Tuple& dashes, double dpi, GCAgg::dash_t& 
dashes_out,
double& dashOffset_out) {
   if (dashes.length()!=2)
 throw Py::ValueError(Printf("Dash descriptor must be a length 2 tuple; 
found %d", dashes.length()).str());
@@ -59,11 +59,11 @@
   dashOffset_out = 0.0;
   if (dashes[0].ptr() == Py_None)
 return;
-  
+
   dashOffset_out = double(Py::Float(dashes[0])) * dpi/72.0;
 
   Py::SeqBase dashSeq = dashes[1];
-  
+
   size_t Ndash = dashSeq.length();
   if (Ndash % 2 != 0)
 throw Py::ValueError(Printf("Dash sequence must be an even length 
sequence; found %d", Ndash).str());
@@ -89,9 +89,9 @@
 public:
   conv_quantize(VertexSource& source, bool quantize) :
 m_source(&source), m_quantize(quantize) {}
-  
-  void rewind(unsigned path_id) { 
-m_source->rewind(path_id); 
+
+  void rewind(unsigned path_id) {
+m_source->rewind(path_id);
   }
 
   unsigned vertex(double* x, double* y) {
@@ -142,9 +142,9 @@
 GCAgg::get_color(const Py::Object& gc) {
   _VERBOSE("GCAgg::get_color");
   Py::Tuple rgb = Py::Tuple( gc.getAttr("_rgb") );
-  
+
   double alpha = Py::Float( gc.getAttr("_alpha") );
-  
+
   double r = Py::Float(rgb[0]);
   double g = Py::Float(rgb[1]);
   double b = Py::Float(rgb[2]);
@@ -161,7 +161,7 @@
 void
 GCAgg::_set_linecap(const Py::Object& gc) {
   _VERBOSE("GCAgg::_set_linecap");
-  
+
   std::string capstyle = Py::String( gc.getAttr( "_capstyle" ) );
 
   if (capstyle=="butt")
@@ -177,9 +177,9 @@
 void
 GCAgg::_set_joinstyle(const Py::Object& gc) {
   _VERBOSE("GCAgg::_set_joinstyle");
-  
+
   std::string joinstyle = Py::String( gc.getAttr("_joinstyle") );
-  
+
   if (joinstyle=="miter")
 join =  agg::miter_join;
   else if (joinstyle=="round")
@@ -194,7 +194,7 @@
 GCAgg::_set_dashes(const Py::Object& gc) {
   //return the dashOffset, dashes sequence tuple.
   _VERBOSE("GCAgg::_set_dashes");
-  
+
   Py::Object dash_obj( gc.getAttr( "_dashes" ) );
   if (dash_obj.ptr() == Py_None) {
 dashes.clear();
@@ -207,7 +207,7 @@
 void
 GCAgg::_set_clip_rectangle( const Py::Object& gc) {
   //set the clip rectangle from the gc
-  
+
   _VERBOSE("GCAgg::_set_clip_rectangle");
 
   Py::Object o ( gc.getAttr( "_cliprect" ) );
@@ -217,9 +217,9 @@
 void
 GCAgg::_set_clip_path( const Py::Object& gc) {
   //set the clip path from the gc
-  
+
   _VERBOSE("GCAgg::_set_clip_path");
-  
+
   Py::Object method_obj = gc.getAttr("get_clip_path");
   Py::Callable method(method_obj);
   Py::Tuple path_and_transform = method.apply(Py::Tuple());
@@ -243,12 +243,12 @@
 {
   _VERBOSE("RendererAgg::RendererAgg");
   unsigned stride(width*4);
-  
-  
+
+
   pixBuffer  = new agg::int8u[NUMBYTES];
   renderingBuffer = new agg::rendering_buffer;
   renderingBuffer->attach(pixBuffer, width, height, stride);
-  
+
   alphaBuffer = new agg::int8u[NUMBYTES];
   alphaMaskRenderingBuffer = new agg::rendering_buffer;
   alphaMaskRenderingBuffer->attach(alphaBuffer, width, height, stride);
@@ -258,33 +258,33 @@
   rendererBaseAlphaMask   = new 
renderer_base_alpha_mask_type(*pixfmtAlphaMask);
   rendererAlphaMask   = new 
renderer_alpha_mask_type(*rendererBaseAlphaMask);
   scanlineAlphaMask   = new agg::scanline_p8();
-  
-  
+
+
   slineP8  = new scanline_p8;
   slineBin = new scanline_bin;
-  
+
   pixFmt   = new pixfmt(*renderingBuffer);
   rendererBase = new renderer_base(*pixFmt);
   rendererBase->clear(agg::rgba(1, 1, 1, 0));
-  
+
   rendererAA   = new renderer_aa(*rendererBase);
   rendererBin  = new renderer_bin(*rendererBase);
   theRasterizer = new rasterizer();
   //theRasterizer->filling_rule(agg::fill_even_odd);
   //theRasterizer->filling_rule(agg::fill_non_zero);
-  
+
 };
 
 template
 void
 RendererAgg::set_clipbox(const Py::Object& cliprect, R rasterizer) {
   //set the clip rectangle from the gc
-  
+
   _VERBOSE("RendererAgg::set_clipbox");
 
   double l, b, r, t;
   if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) {
-rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)), 
+rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)),
 int(round(r)), height - int(round(t)))

SF.net SVN: matplotlib: [4393] branches/transforms

2007-11-20 Thread mdboom
Revision: 4393
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4393&view=rev
Author:   mdboom
Date: 2007-11-20 06:52:24 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Merged revisions 4340-4392 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib


  r4341 | jdh2358 | 2007-11-16 13:15:32 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  removed a couple of pyc files

  r4346 | dsdale | 2007-11-16 16:47:17 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  fixed version checking for traits-3

  r4347 | mdboom | 2007-11-17 07:44:52 -0500 (Sat, 17 Nov 2007) | 1 line
  
  Bugfix: [1655313] axis label disappears when minor tick labels are hidden

  r4374 | efiring | 2007-11-18 13:59:56 -0500 (Sun, 18 Nov 2007) | 11 lines
  
  Let to_rgba return uint8; track changes to cmap
  
  Images require rgba as 4 uint8s, so it is more efficient
  to generate these directly in to_rgba than to generate 4
  doubles and convert them later.
  
  The tracking of changes in ScalarMappable was handling
  communication between objects, but was not keeping track of
  when to_rgba needs to be rerun.  A dictionary was added
  to do this.

  r4375 | efiring | 2007-11-18 14:01:39 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Remove trailing whitespace.

  r4376 | efiring | 2007-11-18 14:02:55 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Use new update_dict from ScalarMappable in QuadMesh

  r4377 | efiring | 2007-11-18 14:06:49 -0500 (Sun, 18 Nov 2007) | 7 lines
  
  Add experimental "pcolorfast" for fast interactive pcolor plots
  
  This will need more discussion and work, but it illustrates
  the potential for very fast pcolor-type plotting with all
  three grid types: uniform, irregular but rectilinear, and
  general quadrilateral.

  r4379 | efiring | 2007-11-18 15:54:22 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Remove unnecessary data copying from draw_quad_mesh

  r4383 | jdh2358 | 2007-11-19 16:43:24 -0500 (Mon, 19 Nov 2007) | 2 lines
  
  fixed a minor bug in csv2rec

  r4387 | mdboom | 2007-11-20 08:13:22 -0500 (Tue, 20 Nov 2007) | 2 lines
  
  Speed improvement initializing mathtext parser.

  r4391 | mdboom | 2007-11-20 08:29:20 -0500 (Tue, 20 Nov 2007) | 2 lines
  
  Fix problem with 0-line width drawing in Postscript.  (Thanks Ben North).


Modified Paths:
--
branches/transforms/lib/matplotlib/axes.py
branches/transforms/lib/matplotlib/axis.py
branches/transforms/lib/matplotlib/backends/backend_ps.py
branches/transforms/lib/matplotlib/cm.py
branches/transforms/lib/matplotlib/collections.py
branches/transforms/lib/matplotlib/image.py
branches/transforms/lib/matplotlib/mlab.py
branches/transforms/lib/matplotlib/pyparsing.py
branches/transforms/setupext.py

Property Changed:

branches/transforms/


Property changes on: branches/transforms
___
Name: svnmerge-integrated
   - /trunk/matplotlib:1-4339
   + /trunk/matplotlib:1-4392

Modified: branches/transforms/lib/matplotlib/axes.py
===
--- branches/transforms/lib/matplotlib/axes.py  2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/axes.py  2007-11-20 14:52:24 UTC (rev 
4393)
@@ -3774,8 +3774,8 @@
 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,
@@ -3801,16 +3801,16 @@
 # 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
-leftlo, ylo = xywhere(left, y, xlolims)
+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():
-
+
 rightup, yup = xywhere(right, y, xuplims)
 caplines.extend( self.plot(rightup,  yup, ls='None', 
marker=mlines.CARETRIGHT, **plot_kw) )
 xuplims = ~xuplims
@@ -3843,7 +3843,7 @@
 
 if uplims.any():
 xup, upperup = xywhere(x, upper, uplims)
-
+
 caplines.extend( self.plot(xup, upperup, ls='None', 
marker=mlines.CARETUP, **plot_kw) )
 uplims = ~uplims
 xup, upperup = xywhere(x, upper, uplims)
@@ -4835,

SF.net SVN: matplotlib: [4395] branches/transforms

2007-11-20 Thread mdboom
Revision: 4395
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4395&view=rev
Author:   mdboom
Date: 2007-11-20 09:44:27 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Merged revisions 4393-4394 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib


  r4394 | mdboom | 2007-11-20 12:43:40 -0500 (Tue, 20 Nov 2007) | 3 lines
  
  Minor refactorings, comments, and one bugfix (to do with the alignment
  of wide accents with STIX fonts).


Modified Paths:
--
branches/transforms/lib/matplotlib/mathtext.py

Property Changed:

branches/transforms/


Property changes on: branches/transforms
___
Name: svnmerge-integrated
   - /trunk/matplotlib:1-4392
   + /trunk/matplotlib:1-4394

Modified: branches/transforms/lib/matplotlib/mathtext.py
===
--- branches/transforms/lib/matplotlib/mathtext.py  2007-11-20 17:43:40 UTC 
(rev 4394)
+++ branches/transforms/lib/matplotlib/mathtext.py  2007-11-20 17:44:27 UTC 
(rev 4395)
@@ -1707,6 +1707,7 @@
 char = char_class(sym, state)
 
 Hlist.__init__(self, [char])
+self.width = char.width
 
 class Ship(object):
 """Once the boxes have been set up, this sends them to output.
@@ -1742,11 +1743,14 @@
 left_edge = self.cur_h
 self.cur_s+= 1
 self.max_push = max(self.cur_s, self.max_push)
-
+clamp = self.clamp
+
 for p in box.children:
 if isinstance(p, Char):
 p.render(self.cur_h + self.off_h, self.cur_v + self.off_v)
 self.cur_h += p.width
+elif isinstance(p, Kern):
+self.cur_h += p.width
 elif isinstance(p, List):
 # @623
 if len(p.children) == 0:
@@ -1785,14 +1789,12 @@
 if glue_sign == 1: # stretching
 if glue_spec.stretch_order == glue_order:
 cur_glue += glue_spec.stretch
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * 
cur_glue))
 elif glue_spec.shrink_order == glue_order:
 cur_glue += glue_spec.shrink
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * cur_glue))
 rule_width += cur_g
 self.cur_h += rule_width
-elif isinstance(p, Kern):
-self.cur_h += p.width
 self.cur_s -= 1
 
 def vlist_out(self, box):
@@ -1805,9 +1807,12 @@
 left_edge = self.cur_h
 self.cur_v-= box.height
 top_edge  = self.cur_v
+clamp = self.clamp
 
 for p in box.children:
-if isinstance(p, List):
+if isinstance(p, Kern):
+self.cur_v += p.width
+elif isinstance(p, List):
 if len(p.children) == 0:
 self.cur_v += p.height + p.depth
 else:
@@ -1840,14 +1845,12 @@
 if glue_sign == 1: # stretching
 if glue_spec.stretch_order == glue_order:
 cur_glue += glue_spec.stretch
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * 
cur_glue))
 elif glue_spec.shrink_order == glue_order: # shrinking
 cur_glue += glue_spec.shrink
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * cur_glue))
 rule_height += cur_g
 self.cur_v += rule_height
-elif isinstance(p, Kern):
-self.cur_v += p.width
 elif isinstance(p, Char):
 raise RuntimeError("Internal mathtext error: Char node found 
in vlist")
 self.cur_s -= 1
@@ -1921,6 +1924,21 @@
 
 _dropsub_symbols = Set(r'''\int \oint'''.split())
 
+_fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split())
+
+_function_names = Set("""
+  arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
+  liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan
+  coth inf max tanh""".split())
+
+_ambiDelim = Set(r"""
+  | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
+  \Downarrow \Updownarrow .""".split())
+
+_leftDelim = Set(r"( [ { \lfloor \langle \lceil".split())
+
+_rightDelim = Set(r") ] } \rfloor \rangle \rceil".split())
+
 def __init__(self):
 # All forward declarations are here
 fon

SF.net SVN: matplotlib: [4394] trunk/matplotlib/lib/matplotlib/mathtext.py

2007-11-20 Thread mdboom
Revision: 4394
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4394&view=rev
Author:   mdboom
Date: 2007-11-20 09:43:40 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Minor refactorings, comments, and one bugfix (to do with the alignment
of wide accents with STIX fonts).

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/mathtext.py

Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-20 14:52:24 UTC (rev 
4393)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-20 17:43:40 UTC (rev 
4394)
@@ -1709,6 +1709,7 @@
 char = char_class(sym, state)
 
 Hlist.__init__(self, [char])
+self.width = char.width
 
 class Ship(object):
 """Once the boxes have been set up, this sends them to output.
@@ -1744,11 +1745,14 @@
 left_edge = self.cur_h
 self.cur_s+= 1
 self.max_push = max(self.cur_s, self.max_push)
-
+clamp = self.clamp
+
 for p in box.children:
 if isinstance(p, Char):
 p.render(self.cur_h + self.off_h, self.cur_v + self.off_v)
 self.cur_h += p.width
+elif isinstance(p, Kern):
+self.cur_h += p.width
 elif isinstance(p, List):
 # @623
 if len(p.children) == 0:
@@ -1787,14 +1791,12 @@
 if glue_sign == 1: # stretching
 if glue_spec.stretch_order == glue_order:
 cur_glue += glue_spec.stretch
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * 
cur_glue))
 elif glue_spec.shrink_order == glue_order:
 cur_glue += glue_spec.shrink
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * cur_glue))
 rule_width += cur_g
 self.cur_h += rule_width
-elif isinstance(p, Kern):
-self.cur_h += p.width
 self.cur_s -= 1
 
 def vlist_out(self, box):
@@ -1807,9 +1809,12 @@
 left_edge = self.cur_h
 self.cur_v-= box.height
 top_edge  = self.cur_v
+clamp = self.clamp
 
 for p in box.children:
-if isinstance(p, List):
+if isinstance(p, Kern):
+self.cur_v += p.width
+elif isinstance(p, List):
 if len(p.children) == 0:
 self.cur_v += p.height + p.depth
 else:
@@ -1842,14 +1847,12 @@
 if glue_sign == 1: # stretching
 if glue_spec.stretch_order == glue_order:
 cur_glue += glue_spec.stretch
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * 
cur_glue))
 elif glue_spec.shrink_order == glue_order: # shrinking
 cur_glue += glue_spec.shrink
-cur_g = round(self.clamp(float(box.glue_set) * 
cur_glue))
+cur_g = round(clamp(float(box.glue_set) * cur_glue))
 rule_height += cur_g
 self.cur_v += rule_height
-elif isinstance(p, Kern):
-self.cur_v += p.width
 elif isinstance(p, Char):
 raise RuntimeError("Internal mathtext error: Char node found 
in vlist")
 self.cur_s -= 1
@@ -1923,6 +1926,21 @@
 
 _dropsub_symbols = Set(r'''\int \oint'''.split())
 
+_fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split())
+
+_function_names = Set("""
+  arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
+  liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan
+  coth inf max tanh""".split())
+
+_ambiDelim = Set(r"""
+  | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
+  \Downarrow \Updownarrow .""".split())
+
+_leftDelim = Set(r"( [ { \lfloor \langle \lceil".split())
+
+_rightDelim = Set(r") ] } \rfloor \rangle \rceil".split())
+
 def __init__(self):
 # All forward declarations are here
 font = Forward().setParseAction(self.font).setName("font")
@@ -1946,15 +1964,10 @@
 
 accent   = oneOf(self._accent_map.keys() + 
list(self._wide_accents))
 
-function = oneOf("arccos csc ker min arcsin deg lg Pr arctan det "
- "lim sec arg dim liminf sin cos exp limsup sinh "
- "cosh gcd ln sup cot hom log tan coth inf max "
- "tanh")
+function = oneOf(list(self._functio

SF.net SVN: matplotlib: [4396] trunk/matplotlib/src

2007-11-20 Thread mdboom
Revision: 4396
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4396&view=rev
Author:   mdboom
Date: 2007-11-20 10:25:33 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Slight speed improvement in draw_quad_mesh.

Modified Paths:
--
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_backend_agg.h

Modified: trunk/matplotlib/src/_backend_agg.cpp
===
--- trunk/matplotlib/src/_backend_agg.cpp   2007-11-20 17:44:27 UTC (rev 
4395)
+++ trunk/matplotlib/src/_backend_agg.cpp   2007-11-20 18:25:33 UTC (rev 
4396)
@@ -956,8 +956,10 @@
   return numIntersect;
 }
 
-void RendererAgg::DrawQuadMesh(int meshWidth, int meshHeight, const agg::rgba8 
colorArray[], const double xCoords[], const double yCoords[])
+void RendererAgg::DrawQuadMesh(int meshWidth, int meshHeight, void* 
colors_void, const double xCoords[], const double yCoords[])
 {
+  PyArrayObject* colors = (PyArrayObject*)colors_void;
+
   /* draw each quadrilateral */
   //   agg::renderer_primitives > 
lineRen(*rendererBase);
   int i = 0;
@@ -992,18 +994,25 @@
  //currTime = clock();
  //timer2 += (clock() - currTime);
  //currTime = clock();
+ size_t color_index = (i * meshWidth) + j;
+ agg::rgba color(*(double*)PyArray_GETPTR2(colors, color_index, 0),
+ *(double*)PyArray_GETPTR2(colors, color_index, 1),
+ *(double*)PyArray_GETPTR2(colors, color_index, 2),
+ *(double*)PyArray_GETPTR2(colors, color_index, 3));
+
  for(k = firstRow; k <= lastRow; k++)
{
  numCol = inPolygon(k, xs, ys, col);
- if (numCol >= 2) rendererBase->copy_hline(col[0], k, col[1] - 1, 
colorArray[(i * meshWidth) + j]);
- if (numCol == 4) rendererBase->copy_hline(col[2], k, col[3] - 1, 
colorArray[(i * meshWidth) + j]);
+ 
+ if (numCol >= 2) rendererBase->copy_hline(col[0], k, col[1] - 1, 
color);
+ if (numCol == 4) rendererBase->copy_hline(col[2], k, col[3] - 1, 
color);
}
}
 }
   return;
 }
 
-void RendererAgg::DrawQuadMeshEdges(int meshWidth, int meshHeight, const 
agg::rgba8 colorArray[], const double xCoords[], const double yCoords[])
+void RendererAgg::DrawQuadMeshEdges(int meshWidth, int meshHeight, const 
double xCoords[], const double yCoords[])
 {
   int i, j;
   agg::renderer_primitives > 
lineRen(*rendererBase);
@@ -1027,7 +1036,6 @@
 
 Py::Object
 RendererAgg::draw_quad_mesh(const Py::Tuple& args){
-
   //printf("#1: %d\n", clock());
   Py::Object colorsi = args[2];
   Py::Object xCoordsi = args[3];
@@ -1035,7 +1043,6 @@
   int meshWidth = Py::Int(args[0]);
   int meshHeight = Py::Int(args[1]);
   int showedges = Py::Int(args[9]);
-  int numQuads = (meshWidth * meshHeight);
   PyArrayObject *colors = (PyArrayObject *) 
PyArray_ContiguousFromObject(colorsi.ptr(), PyArray_DOUBLE, 2, 2);
   PyArrayObject *xCoords = (PyArrayObject *) 
PyArray_ContiguousFromObject(xCoordsi.ptr(), PyArray_DOUBLE, 1, 1);
   PyArrayObject *yCoords = (PyArrayObject *) 
PyArray_ContiguousFromObject(yCoordsi.ptr(), PyArray_DOUBLE, 1, 1);
@@ -1117,30 +1124,14 @@
 
   / End of transformations /
 
-  /* convert colors */
-  double r;
-  double g;
-  double b;
-  double a;
-  int i;
-  agg::rgba8* colorArray = new agg::rgba8[numQuads];
-  for(i=0; i < numQuads; i++)
-{
-  r = *(double *)(colors -> data + i*(colors -> strides[0]));
-  g = *(double *)(colors -> data + i*(colors -> strides[0]) + (colors -> 
strides[1]));
-  b = *(double *)(colors -> data + i*(colors -> strides[0]) + 2*(colors -> 
strides[1]));
-  a = *(double *)(colors -> data + i*(colors -> strides[0]) + 3*(colors -> 
strides[1]));
-  colorArray[i] = agg::rgba8((int)(255.0 * r), (int)(255.0 * g), 
(int)(255.0 * b), (int)(255.0 * a));
-}
-  DrawQuadMesh(meshWidth, meshHeight, colorArray, &(newXCoords[0]), 
&(newYCoords[0]));
+  DrawQuadMesh(meshWidth, meshHeight, colors, &(newXCoords[0]), 
&(newYCoords[0]));
   if(showedges)
-DrawQuadMeshEdges(meshWidth, meshHeight, colorArray, &(newXCoords[0]), 
&(newYCoords[0]));
+DrawQuadMeshEdges(meshWidth, meshHeight, &(newXCoords[0]), 
&(newYCoords[0]));
   Py_XDECREF(xCoords);
   Py_XDECREF(yCoords);
   Py_XDECREF(colors);
   delete newXCoords;
   delete newYCoords;
-  delete colorArray;
   //printf("#2: %d\n", clock());
   return Py::Object();
 }

Modified: trunk/matplotlib/src/_backend_agg.h
===
--- trunk/matplotlib/src/_backend_agg.h 2007-11-20 17:44:27 UTC (rev 4395)
+++ trunk/matplotlib/src/_backend_agg.h 2007-11-20 18:25:33 UTC (rev 4396)
@@ -215,8 +215,8 @@
   agg::rect bbox_to_rect( const Py::Object& o);
   double points_to_pixels( const Py::Object& points);
   double points_to_pixels_snapto( const Py::Object& points);
-  void DrawQuadMesh(int,

SF.net SVN: matplotlib: [4397] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-20 Thread jswhit
Revision: 4397
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4397&view=rev
Author:   jswhit
Date: 2007-11-20 12:21:53 -0800 (Tue, 20 Nov 2007)

Log Message:
---
fix drawlsmask for 'moll','robin' and 'sinu' projections.

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-20 18:25:33 UTC (rev 4396)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-20 20:21:53 UTC (rev 4397)
@@ -2461,8 +2461,22 @@
 nx = int((self.xmax-self.xmin)/dx)+1; ny = 
int((self.ymax-self.ymin)/dx)+1
 # interpolate rgba values from proj='cyl' (geographic coords)
 # to a rectangular map projection grid.
-mask = self.transform_scalar(lsmask,lsmask_lons,\
- lsmask_lats,nx,ny,order=0,masked=255)
+mask,x,y = self.transform_scalar(lsmask,lsmask_lons,\
+   lsmask_lats,nx,ny,returnxy=True,order=0,masked=255)
+# for these projections, points outside the projection
+# limb have to be set to transparent manually.
+if self.projection in ['moll','robin','sinu']:
+lons, lats = self(x, y, inverse=True)
+lon_0 = self.projparams['lon_0']
+lats = lats[:,nx/2]
+lons1 = (lon_0+180.)*npy.ones(lons.shape[0],npy.float64)
+lons2 = (lon_0-180.)*npy.ones(lons.shape[0],npy.float64)
+xmax,ytmp = self(lons1,lats)
+xmin,ytmp = self(lons2,lats)
+for j in range(lats.shape[0]):
+xx = x[j,:]
+mask[j,:]=npy.where(npy.logical_or(xxxmax[j]),\
+255,mask[j,:])
 self.lsmask = mask
 # optionally, set lakes to ocean color.
 if lakes:
@@ -2479,6 +2493,7 @@
 rgba[:,:,3] = npy.where(mask==255,0,rgba[:,:,3])
 # plot mask as rgba image.
 im = self.imshow(rgba,interpolation='nearest',ax=ax,**kwargs)
+return im
 
 ### End of Basemap class
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib: [4398] branches/transforms/lib/matplotlib

2007-11-20 Thread mdboom
Revision: 4398
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4398&view=rev
Author:   mdboom
Date: 2007-11-20 13:00:20 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Support mixed-mode rendering the PDF backend.  This allows some things
to be rendered as vectors and some as rasters.  At the moment, mostly
as a proof-of-concept, all quadmeshes are rendered as rasters with the
PDF backend.
Also make PDF backend resolution independent.

Modified Paths:
--
branches/transforms/lib/matplotlib/backend_bases.py
branches/transforms/lib/matplotlib/backends/backend_pdf.py
branches/transforms/lib/matplotlib/collections.py

Added Paths:
---
branches/transforms/lib/matplotlib/backends/backend_mixed.py

Modified: branches/transforms/lib/matplotlib/backend_bases.py
===
--- branches/transforms/lib/matplotlib/backend_bases.py 2007-11-20 20:21:53 UTC 
(rev 4397)
+++ branches/transforms/lib/matplotlib/backend_bases.py 2007-11-20 21:00:20 UTC 
(rev 4398)
@@ -9,6 +9,7 @@
 import numpy as npy
 import matplotlib.cbook as cbook
 import matplotlib.colors as colors
+import matplotlib._image as _image
 import matplotlib.path as path
 import matplotlib.transforms as transforms
 import matplotlib.widgets as widgets
@@ -328,7 +329,13 @@
 def strip_math(self, s):
 return cbook.strip_math(s)
 
+def start_rasterizing(self):
+pass
 
+def stop_rasterizing(self):
+pass
+
+
 class GraphicsContextBase:
 """An abstract base class that provides color, line styles, etc...
 """

Added: branches/transforms/lib/matplotlib/backends/backend_mixed.py
===
--- branches/transforms/lib/matplotlib/backends/backend_mixed.py
(rev 0)
+++ branches/transforms/lib/matplotlib/backends/backend_mixed.py
2007-11-20 21:00:20 UTC (rev 4398)
@@ -0,0 +1,142 @@
+from matplotlib._image import frombuffer
+from matplotlib.backends.backend_agg import RendererAgg
+
+class MixedModeRenderer(object):
+"""
+A helper class to implement a renderer that switches between
+vector and raster drawing.  An example may be a PDF writer, where
+most things are drawn with PDF vector commands, but some very
+complex objects, such as quad meshes, are rasterised and then
+output as images.
+"""
+def __init__(self, width, height, dpi, vector_renderer, 
raster_renderer_class=None):
+"""
+width: The width of the canvas in logical units
+
+height: The height of the canvas in logical units
+
+dpi: The dpi of the canvas
+
+vector_renderer: An instance of a subclass of RendererBase
+that will be used for the vector drawing.
+
+raster_renderer_class: The renderer class to use for the
+raster drawing.  If not provided, this will use the Agg
+backend (which is currently the only viable option anyway.)
+"""
+if raster_renderer_class is None:
+raster_renderer_class = RendererAgg
+
+self._raster_renderer_class = raster_renderer_class
+self._width = width
+self._height = height
+self._dpi = dpi
+
+assert not vector_renderer.option_image_nocomposite()
+self._vector_renderer = vector_renderer
+vector_renderer.start_rasterizing = self.start_rasterizing
+vector_renderer.stop_rasterizing = self.stop_rasterizing
+
+self._raster_renderer = None
+self._rasterizing = False
+
+self._renderer = self._vector_renderer
+
+def start_rasterizing(self):
+"""
+Enter "raster" mode.  All subsequent drawing commands (until
+stop_rasterizing is called) will be drawn with the raster
+backend.
+
+If start_rasterizing is called multiple times before
+stop_rasterizing is called, this method has no effect.
+"""
+if not self._rasterizing:
+self._raster_renderer = self._raster_renderer_class(
+self._width*self._dpi, self._height*self._dpi, self._dpi)
+self._raster_renderer.start_rasterizing = self.start_rasterizing
+self._raster_renderer.stop_rasterizing = self.stop_rasterizing
+self._renderer = self._raster_renderer
+self._rasterizing = True
+
+def stop_rasterizing(self):
+"""
+Exit "raster" mode.  All of the drawing that was done since
+the last start_rasterizing command will be copied to the
+vector backend by calling draw_image.
+
+If stop_rasterizing is called multiple times before
+start_rasterizing is called, this method has no effect.
+"""
+if self._rasterizing:
+width, height = self._width * self._dpi, self._height * self._dpi
+buffer = self._raster_renderer.buffer_rgba(0, 0)
+image = fromb

SF.net SVN: matplotlib: [4399] branches/transforms

2007-11-20 Thread mdboom
Revision: 4399
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4399&view=rev
Author:   mdboom
Date: 2007-11-20 14:00:51 -0800 (Tue, 20 Nov 2007)

Log Message:
---
Reduce file sizes for mixed-mode PDFs by only outputting the part of
the image with non-transparent pixels.
Minor speed improvement in MixedModeRenderer.

Modified Paths:
--
branches/transforms/lib/matplotlib/backends/backend_agg.py
branches/transforms/lib/matplotlib/backends/backend_mixed.py
branches/transforms/src/_backend_agg.cpp
branches/transforms/src/_backend_agg.h

Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py
===
--- branches/transforms/lib/matplotlib/backends/backend_agg.py  2007-11-20 
21:00:20 UTC (rev 4398)
+++ branches/transforms/lib/matplotlib/backends/backend_agg.py  2007-11-20 
22:00:51 UTC (rev 4399)
@@ -68,6 +68,7 @@
 self.draw_image = self._renderer.draw_image
 self.copy_from_bbox = self._renderer.copy_from_bbox
 self.restore_region = self._renderer.restore_region
+self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
 self.mathtext_parser = MathTextParser('Agg')
 self._fontd = {}
 

Modified: branches/transforms/lib/matplotlib/backends/backend_mixed.py
===
--- branches/transforms/lib/matplotlib/backends/backend_mixed.py
2007-11-20 21:00:20 UTC (rev 4398)
+++ branches/transforms/lib/matplotlib/backends/backend_mixed.py
2007-11-20 22:00:51 UTC (rev 4399)
@@ -34,14 +34,28 @@
 
 assert not vector_renderer.option_image_nocomposite()
 self._vector_renderer = vector_renderer
-vector_renderer.start_rasterizing = self.start_rasterizing
-vector_renderer.stop_rasterizing = self.stop_rasterizing
 
 self._raster_renderer = None
 self._rasterizing = False
 
-self._renderer = self._vector_renderer
+self._set_current_renderer(vector_renderer)
 
+_methods = """
+open_group close_group draw_path draw_markers
+draw_path_collection draw_quad_mesh get_image_magnification
+draw_image draw_tex draw_text flipy option_image_nocomposite
+get_texmanager get_text_width_height_descent new_gc
+points_to_pixels strip_math finalize
+""".split()
+def _set_current_renderer(self, renderer):
+self._renderer = renderer
+
+for method in self._methods:
+if hasattr(renderer, method):
+setattr(self, method, getattr(renderer, method))
+renderer.start_rasterizing = self.start_rasterizing
+renderer.stop_rasterizing = self.stop_rasterizing
+
 def start_rasterizing(self):
 """
 Enter "raster" mode.  All subsequent drawing commands (until
@@ -54,9 +68,7 @@
 if not self._rasterizing:
 self._raster_renderer = self._raster_renderer_class(
 self._width*self._dpi, self._height*self._dpi, self._dpi)
-self._raster_renderer.start_rasterizing = self.start_rasterizing
-self._raster_renderer.stop_rasterizing = self.stop_rasterizing
-self._renderer = self._raster_renderer
+self._set_current_renderer(self._raster_renderer)
 self._rasterizing = True
 
 def stop_rasterizing(self):
@@ -69,74 +81,19 @@
 start_rasterizing is called, this method has no effect.
 """
 if self._rasterizing:
+self._set_current_renderer(self._vector_renderer)
+
 width, height = self._width * self._dpi, self._height * self._dpi
-buffer = self._raster_renderer.buffer_rgba(0, 0)
-image = frombuffer(buffer, width, height, True)
-image.is_grayscale = False
+buffer, bounds = self._raster_renderer.tostring_rgba_minimized()
+l, b, w, h = bounds
+if w > 0 and h > 0:
+image = frombuffer(buffer, w, h, True)
+image.is_grayscale = False
 
-self._renderer = self._vector_renderer
-self._renderer.draw_image(0, 0, image, None)
+self._renderer.draw_image(l, height - b - h, image, None)
 self._raster_renderer = None
 self._rasterizing = False
 
 def get_canvas_width_height(self):
 'return the canvas width and height in display coords'
 return self._width, self._height
-
-# The rest of this methods simply delegate to the currently active
-# rendering backend.
-
-def open_group(self, *args, **kwargs):
-return self._renderer.open_group(*args, **kwargs)
-
-def close_group(self, *args, **kwargs):
-return self._renderer.close_group(*args, **kwargs)
-
-def draw_path(self, *args, **kwargs):
-return self._renderer.draw_path(*args, **kwargs