Revision: 7562
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7562&view=rev
Author:   jswhit
Date:     2009-08-24 22:45:15 +0000 (Mon, 24 Aug 2009)

Log Message:
-----------
add zorder keyword to nightshade

Modified Paths:
--------------
    trunk/toolkits/basemap/examples/daynight.py

Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py 2009-08-24 22:34:25 UTC (rev 
7561)
+++ trunk/toolkits/basemap/examples/daynight.py 2009-08-24 22:45:15 UTC (rev 
7562)
@@ -64,14 +64,22 @@
     return lons2,lats2,daynight
 
 class Basemap2(Basemap):
-    def nightshade(self,color="0.5",nlons=1441,alpha=0.5):
+    def nightshade(self,color="0.5",nlons=1441,alpha=0.5,zorder=None):
         # create grid of day=0, night=1
         # 1441 means use a 0.25 degree grid.
         lons,lats,daynight = daynightgrid(d,nlons)
         x,y = self(lons,lats)
         # contour the day-night grid, coloring the night area
         # with the specified color and transparency.
-        return map.contourf(x,y,daynight,1,colors=[color],alpha=alpha)
+        CS = map.contourf(x,y,daynight,1,colors=[color],alpha=alpha)
+        # set zorder on ContourSet collections show night shading
+        # is on top.
+        for c in CS.collections:
+            if zorder is None:
+               c.set_zorder(c.get_zorder()+1)
+            else:
+               c.set_zorder(zorder)
+        return CS
 
 # current time in UTC.
 d = datetime.utcnow()
@@ -84,9 +92,9 @@
 map.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
 # fill continents 'coral' (with zorder=0), color wet areas 'aqua'
 map.drawmapboundary(fill_color='aqua')
-map.fillcontinents(color='coral',lake_color='aqua',zorder=0)
+map.fillcontinents(color='coral',lake_color='aqua')
 # shade the night areas gray, with alpha transparency so the 
 # map shows through.
-map.nightshade(color="0.5",nlons=1441,alpha=0.5)
+CS=map.nightshade()
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to