All (and Jeff W. in particular),

It's the time of the year where I have to draw maps in batch. I wrote  
a script to process some data recorded at various stations,  
interpolate the data on a grid, draw the corresponding contours on a  
basemap, add a colorbar, and end with adding some extra information on  
the map (scale, stations positions...).

Nothing too fancy, but I ran into a problem with the last few steps.  
As I do not give an explicit 'ax' parameter to any of the basemap  
related methods (.contourf, .plot, .drawmapscale...), I have to rely  
on the defaults: use self.ax if it is not None, gca() otherwise.  
However, drawing a colorbar in midprocess switches the focus to the  
colorbar, and the extra information I was talking about gets plotted  
on the colorbar.

Which brings me to the famous question: is it a bug or a feature ? Is  
there any rational in *not* setting the 'ax' attribute to gca() when  
sit hasn't been set yet and no 'ax' parameter has been specifically  
given as input of a method ?

Thanks a lot in advance for any explanation:
P.


[As a workaround, I modified my local sources by adding a ._check_ax  
method as below, and used :
ax = ax or self._check_ax(ax)
or
ax = kwargs.pop('ax', None) or self._check_ax()
depending on the context

     def _check_ax(self, ax=None):
         """
     Returns the axis on which to draw.
     By default, returns self.ax. If this latter is None, set it to  
gca().
         """
         #
         if ax is None:
             if self.ax is None:
                 try:
                     ax = plt.gca()
                 except:
                     import matplotlib.pyplot as plt
                     ax = plt.gca()
                 self.ax = ax
             return self.ax
         return ax

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to