From: Michael B. <mb...@jp...> - 2005-03-29 17:17:37
|
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@... ======================================================================== |