[Numpy-tickets] [NumPy] #489: Filling polygons with Basemap

NumPy numpy-tickets@scipy....
Mon Apr 2 16:48:32 CDT 2007


#489: Filling polygons with Basemap
-------------------------+--------------------------------------------------
 Reporter:  jbmichel     |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  normal       |   Milestone:          
Component:  Other        |     Version:  none    
 Severity:  normal       |    Keywords:          
-------------------------+--------------------------------------------------
 Basemap had no simple function for filling polygons - wich can be very
 useful if one wants to represent countries with different colors,
 corresponding to some social or economic parameter for instance.

 One can copy/paste Basemap's "plot" function and only replace the word
 "plot" by the word "fill". This yields good results. The code to add is
 exactly:





 {{{
    def fill(self, *args, **kwargs):
         """
  Draw lines and/or markers on the map (see pylab.plot documentation).
  extra keyword 'ax' can be used to override the default axis instance.
         """
         if not kwargs.has_key('ax') and self.ax is None:
             try:
                 ax = pylab.gca()
             except:
                 import pylab
                 ax = pylab.gca()
         elif not kwargs.has_key('ax') and self.ax is not None:
             ax = self.ax
         else:
             ax = popd(kwargs,'ax')
         # allow callers to override the hold state by passing
 hold=True|False
         b = ax.ishold()
         h = popd(kwargs, 'hold', None)
         if h is not None:
             ax.hold(h)
         try:
             ret =  ax.fill(*args, **kwargs)
             try:
                 pylab.draw_if_interactive()
             except:
                 pass
         except:
             ax.hold(b)
             raise
         ax.hold(b)
         # set axes limits to fit map region.
         self.set_axes_limits(ax=ax)
         # make sure axis ticks are turned off.
         if self.noticks:
             ax.set_xticks([])
             ax.set_yticks([])
         return ret
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/489>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list