Basemap Mercator y-axis latitude ticks

When using Basemap with a Mercator projection, is there a simple way to tell the Axes to label the y-axis ticks in latitude degrees instead of native map coord meters?

Here's the way I did it. I created my own Formatter:

class MercYAxisFormatter( matplotlib.ticker.Formatter ):
    """The format function for Mercator projection Y-axis.
    Translates plot y in meters to latitude.
    """

    def __init__( self, baseMap ):
       self.baseMap = baseMap

    def __call__( self, y, pos=1 ):
       """Return the label for tick value y at position pos.
       """

       lon, lat = self.baseMap( 0.0, y, inverse=True )
       return "%.0f" % lat

and added it like so:

   baseMap = Basemap( ... )
   ax.yaxis.set_major_formatter( MercYAxisFormatter( baseMap ) )

This works just fine, but is there a simple one-liner in Basemap that I'm missing that does this?

Thanks,

Michael

···

--

  Michael Brady
  Jet Propulsion Laboratory (M/S 301-140L)
  4800 Oak Grove Drive
  Pasadena, CA 91109 E-mail: Michael.Brady@...83...

Michael Brady wrote:

When using Basemap with a Mercator projection, is there a simple way to tell the Axes to label the y-axis ticks in latitude degrees instead of native map coord meters?

Here's the way I did it. I created my own Formatter:

class MercYAxisFormatter( matplotlib.ticker.Formatter ):
   """The format function for Mercator projection Y-axis.
   Translates plot y in meters to latitude.
   """

   def __init__( self, baseMap ):
      self.baseMap = baseMap

   def __call__( self, y, pos=1 ):
      """Return the label for tick value y at position pos.
      """

      lon, lat = self.baseMap( 0.0, y, inverse=True )
      return "%.0f" % lat

and added it like so:

  baseMap = Basemap( ... )
  ax.yaxis.set_major_formatter( MercYAxisFormatter( baseMap ) )

This works just fine, but is there a simple one-liner in Basemap that I'm missing that does this?

Thanks,

Michael

Michael: No, you're not missing anything - the functionality of basemap is rather basic at this point. Thanks for the tip though!

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg