SF.net SVN: matplotlib:[7069] trunk/matplotlib/lib/matplotlib/backends/ backend_cairo.py

2009-04-29 Thread mdboom
Revision: 7069
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7069&view=rev
Author:   mdboom
Date: 2009-04-29 15:28:33 + (Wed, 29 Apr 2009)

Log Message:
---
Fix bug in Cairo backend due to  changes in convert_path, reported by Michiel 
de Hoon

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

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py   2009-04-28 
19:48:18 UTC (rev 7068)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py   2009-04-29 
15:28:33 UTC (rev 7069)
@@ -122,8 +122,7 @@
 tpath, affine = clippath.get_transformed_path_and_affine()
 ctx.new_path()
 affine = affine + Affine2D().scale(1.0, -1.0).translate(0.0, 
self.height)
-tpath = affine.transform_path(tpath)
-RendererCairo.convert_path(ctx, tpath)
+RendererCairo.convert_path(ctx, tpath, affine)
 ctx.clip()
 
 def _fill_and_stroke (self, ctx, fill_c, alpha):
@@ -184,9 +183,8 @@
 ctx = self.ctx
 ctx.save()
 if clippath is not None:
-tpath = clippath_trans.transform_path(clippath)
 ctx.new_path()
-RendererCairo.convert_path(ctx, tpath)
+RendererCairo.convert_path(ctx, clippath, clippath_trans)
 ctx.clip()
 y = self.height - y - rows
 ctx.set_source_surface (surface, x, y)


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

--
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7070] trunk/matplotlib

2009-04-29 Thread jdh2358
Revision: 7070
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7070&view=rev
Author:   jdh2358
Date: 2009-04-29 16:07:27 + (Wed, 29 Apr 2009)

Log Message:
---
add masked array support to fill_between

Modified Paths:
--
trunk/matplotlib/examples/user_interfaces/embedding_in_gtk.py
trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py
trunk/matplotlib/lib/matplotlib/axes.py

Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_gtk.py
===
--- trunk/matplotlib/examples/user_interfaces/embedding_in_gtk.py   
2009-04-29 15:28:33 UTC (rev 7069)
+++ trunk/matplotlib/examples/user_interfaces/embedding_in_gtk.py   
2009-04-29 16:07:27 UTC (rev 7070)
@@ -10,8 +10,8 @@
 from numpy import arange, sin, pi
 
 # uncomment to select /GTK/GTKAgg/GTKCairo
-from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
-#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as 
FigureCanvas
+#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
+from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as 
FigureCanvas
 #from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as 
FigureCanvas
 
 

Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py
===
--- trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py  
2009-04-29 15:28:33 UTC (rev 7069)
+++ trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py  
2009-04-29 16:07:27 UTC (rev 7070)
@@ -9,8 +9,8 @@
 from numpy import arange, sin, pi
 
 # uncomment to select /GTK/GTKAgg/GTKCairo
-from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
-#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as 
FigureCanvas
+#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
+from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as 
FigureCanvas
 #from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as 
FigureCanvas
 
 # or NavigationToolbar for classic

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-04-29 15:28:33 UTC (rev 
7069)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-04-29 16:07:27 UTC (rev 
7070)
@@ -5832,6 +5832,26 @@
 self._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)
 self._process_unit_info(ydata=y2)
 
+if where is None:
+where = np.ones(len(x), np.bool)
+else:
+where = np.asarray(where)
+
+maskedx = isinstance(x, np.ma.MaskedArray)
+maskedy1 = isinstance(y1, np.ma.MaskedArray)
+maskedy2 = isinstance(y2, np.ma.MaskedArray)
+
+if (maskedx or maskedy1 or maskedy2):
+if maskedx:
+where = where & (~x.mask)
+
+if maskedy1:
+where = where & (~y1.mask)
+
+if maskedy2:
+where = where & (~y2.mask)
+
+
 # Convert the arrays so we can work with them
 x = np.asarray(self.convert_xunits(x))
 y1 = np.asarray(self.convert_yunits(y1))
@@ -5843,10 +5863,7 @@
 if not cbook.iterable(y2):
 y2 = np.ones_like(x)*y2
 
-if where is None:
-where = np.ones(len(x), np.bool)
 
-where = np.asarray(where)
 assert( (len(x)==len(y1)) and (len(x)==len(y2)) and len(x)==len(where))
 
 polys = []


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

--
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[7071] trunk/matplotlib

2009-04-29 Thread efiring
Revision: 7071
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7071&view=rev
Author:   efiring
Date: 2009-04-29 19:38:35 + (Wed, 29 Apr 2009)

Log Message:
---
Condense argument handling in fill_between, and add masked example

Modified Paths:
--
trunk/matplotlib/examples/pylab_examples/fill_between.py
trunk/matplotlib/lib/matplotlib/axes.py

Modified: trunk/matplotlib/examples/pylab_examples/fill_between.py
===
--- trunk/matplotlib/examples/pylab_examples/fill_between.py2009-04-29 
16:07:27 UTC (rev 7070)
+++ trunk/matplotlib/examples/pylab_examples/fill_between.py2009-04-29 
19:38:35 UTC (rev 7071)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 import matplotlib.mlab as mlab
-from pylab import figure, show
+from matplotlib.pyplot import figure, show
 import numpy as np
 
 x = np.arange(0.0, 2, 0.01)
@@ -27,11 +27,24 @@
 #   fill_between(x[where], y1[where],y2[where]
 # because of edge effects over multiple contiguous regions.
 fig = figure()
-ax = fig.add_subplot(111)
+ax = fig.add_subplot(211)
 ax.plot(x, y1, x, y2, color='black')
-ax.fill_between(x, y1, y2, where=y2>y1, facecolor='green')
+ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
 ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
 ax.set_title('fill between where')
 
+# Test support for masked arrays.
+y2 = np.ma.masked_greater(y2, 1.0)
+ax1 = fig.add_subplot(212, sharex=ax)
+ax1.plot(x, y1, x, y2, color='black')
+ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
+ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
+ax1.set_title('Now regions with y2>1 are masked')
+
+# This example illustrates a problem; because of the data
+# gridding, there are undesired unfilled triangles at the crossover
+# points.  A brute-force solution would be to interpolate all
+# arrays to a very fine grid before plotting.
+
 show()
 

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-04-29 16:07:27 UTC (rev 
7070)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-04-29 19:38:35 UTC (rev 
7071)
@@ -5832,40 +5832,29 @@
 self._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)
 self._process_unit_info(ydata=y2)
 
-if where is None:
-where = np.ones(len(x), np.bool)
-else:
-where = np.asarray(where)
-
-maskedx = isinstance(x, np.ma.MaskedArray)
-maskedy1 = isinstance(y1, np.ma.MaskedArray)
-maskedy2 = isinstance(y2, np.ma.MaskedArray)
-
-if (maskedx or maskedy1 or maskedy2):
-if maskedx:
-where = where & (~x.mask)
-
-if maskedy1:
-where = where & (~y1.mask)
-
-if maskedy2:
-where = where & (~y2.mask)
-
-
 # Convert the arrays so we can work with them
-x = np.asarray(self.convert_xunits(x))
-y1 = np.asarray(self.convert_yunits(y1))
-y2 = np.asarray(self.convert_yunits(y2))
+x = np.asanyarray(self.convert_xunits(x))
+y1 = np.asanyarray(self.convert_yunits(y1))
+y2 = np.asanyarray(self.convert_yunits(y2))
 
-if not cbook.iterable(y1):
+if y1.ndim == 0:
 y1 = np.ones_like(x)*y1
-
-if not cbook.iterable(y2):
+if y2.ndim == 0:
 y2 = np.ones_like(x)*y2
 
+if where is None:
+where = np.ones(len(x), np.bool)
+else:
+where = np.asarray(where, np.bool)
 
-assert( (len(x)==len(y1)) and (len(x)==len(y2)) and len(x)==len(where))
+if not (x.shape == y1.shape == y2.shape == where.shape):
+raise ValueError("Argument dimensions are incompatible")
 
+mask = reduce(ma.mask_or,
+[ma.getmask(x), ma.getmask(y1), ma.getmask(y2)])
+if mask is not ma.nomask:
+where &= ~mask
+
 polys = []
 for ind0, ind1 in mlab.contiguous_regions(where):
 theseverts = []


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

--
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins