Revision: 7994
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7994&view=rev
Author:   jdh2358
Date:     2009-12-01 03:50:21 +0000 (Tue, 01 Dec 2009)

Log Message:
-----------
add zorder to figure drawing

Modified Paths:
--------------
    trunk/matplotlib/doc/pyplots/pyplot_simple.py
    trunk/matplotlib/examples/pylab_examples/figimage_demo.py
    trunk/matplotlib/lib/matplotlib/figure.py
    trunk/matplotlib/lib/matplotlib/pyplot.py

Modified: trunk/matplotlib/doc/pyplots/pyplot_simple.py
===================================================================
--- trunk/matplotlib/doc/pyplots/pyplot_simple.py       2009-11-30 21:38:58 UTC 
(rev 7993)
+++ trunk/matplotlib/doc/pyplots/pyplot_simple.py       2009-12-01 03:50:21 UTC 
(rev 7994)
@@ -1,4 +1,4 @@
 import matplotlib.pyplot as plt
-plt.plot([1,2,3])
+plt.plot([1,2,3,4])
 plt.ylabel('some numbers')
 plt.show()

Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/figimage_demo.py   2009-11-30 
21:38:58 UTC (rev 7993)
+++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py   2009-12-01 
03:50:21 UTC (rev 7994)
@@ -12,6 +12,9 @@
 Z.shape = 100,100
 Z[:,50:] = 1.
 
+ax = fig.add_subplot(111)
+ax.grid(True)
+
 im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet, origin='lower')
 im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet, origin='lower')
 

Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py   2009-11-30 21:38:58 UTC (rev 
7993)
+++ trunk/matplotlib/lib/matplotlib/figure.py   2009-12-01 03:50:21 UTC (rev 
7994)
@@ -343,7 +343,8 @@
                  cmap=None,
                  vmin=None,
                  vmax=None,
-                 origin=None):
+                 origin=None,
+                 **kwargs):
         """
         call signatures::
 
@@ -393,11 +394,14 @@
 
         .. plot:: mpl_examples/pylab_examples/figimage_demo.py
 
+
+        Additional kwargs are Artist kwargs passed on to
+        :class:`~matplotlib.image.FigureImage`
         """
 
         if not self._hold: self.clf()
 
-        im = FigureImage(self, cmap, norm, xo, yo, origin)
+        im = FigureImage(self, cmap, norm, xo, yo, origin, **kwargs)
         im.set_array(X)
         im.set_alpha(alpha)
         if norm is None:
@@ -735,11 +739,20 @@
 
         if self.frameon: self.patch.draw(renderer)
 
+        # a list of (zorder, func_to_call, list_of_args)
+        dsu = []
+
+
         # todo: respect zorder
-        for p in self.patches: p.draw(renderer)
-        for l in self.lines: l.draw(renderer)
-        for a in self.artists: a.draw(renderer)
+        for a in self.patches:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
 
+        for a in self.lines:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
+
+        for a in self.artists:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
+
         # override the renderer default if self.suppressComposite
         # is not None
         composite = renderer.option_image_nocomposite()
@@ -747,8 +760,8 @@
             composite = self.suppressComposite
 
         if len(self.images)<=1 or composite or not allequal([im.origin for im 
in self.images]):
-            for im in self.images:
-                im.draw(renderer)
+            for a in self.images:
+                dsu.append( (a.get_zorder(), a.draw, [renderer]))
         else:
             # make a composite image blending alpha
             # list of (_image.Image, ox, oy)
@@ -762,21 +775,33 @@
 
             im.is_grayscale = False
             l, b, w, h = self.bbox.bounds
-            gc = renderer.new_gc()
-            gc.set_clip_rectangle(self.bbox)
-            gc.set_clip_path(self.get_clip_path())
-            renderer.draw_image(gc, l, b, im)
-            gc.restore()
 
+            def draw_composite():
+                gc = renderer.new_gc()
+                gc.set_clip_rectangle(self.bbox)
+                gc.set_clip_path(self.get_clip_path())
+                renderer.draw_image(gc, l, b, im)
+                gc.restore()
+
+            if len(ims):
+                dsu.append((ims[0].get_zorder(), draw_composite, []))
+
         # render the axes
-        for a in self.axes: a.draw(renderer)
+        for a in self.axes:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
 
         # render the figure text
-        for t in self.texts: t.draw(renderer)
+        for a in self.texts:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
 
-        for legend in self.legends:
-            legend.draw(renderer)
+        for a in self.legends:
+            dsu.append( (a.get_zorder(), a.draw, [renderer]))
 
+
+        dsu.sort()
+        for zorder, func, args in dsu:
+            func(*args)
+
         renderer.close_group('figure')
 
         self._cachedRenderer = renderer
@@ -1045,7 +1070,7 @@
         if args and is_string_like(args[0]) and '.' not in args[0] and 
extension != 'auto':
             fname = args[0] + '.' + extension
             args = (fname,) + args[1:]
-                
+
         transparent = kwargs.pop('transparent', False)
         if transparent:
             original_figure_alpha = self.patch.get_alpha()

Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py   2009-11-30 21:38:58 UTC (rev 
7993)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py   2009-12-01 03:50:21 UTC (rev 
7994)
@@ -401,7 +401,7 @@
     # allow callers to override the hold state by passing hold=True|False
     ret =  gcf().figimage(*args, **kwargs)
     draw_if_interactive()
-    sci(ret)
+    #sci(ret)  # JDH figimage should not set current image -- it is not 
mappable, etc
     return ret
 
 def figlegend(handles, labels, loc, **kwargs):


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

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to