Basemap with origin within the plot

Pascoe, S (Stephen) wrote:

Thanks Jeff,

Unfortunately another issue is with plotting the axes tick labels. This
output is for a public service where the users expect to see eastings
and northings displayed from the official UK national grid origin. I
can use standard matplotlib axes to produce eastings/northings but with
your solution the origin would be shown as in the wrong place.

I can envisage solving this by creating a tick Formatter object that
offsets the axes. Maybe that is my solution but I was hoping for a
simpler way.

Stephen: Using a TickFormatter is probably the best solution. -Jeff

P.S. Could you send me an example when you're done - perhaps to include in the examples directory?


Stephen Pascoe +44 (0)1235 445980
British Atmospheric Data Centre
Rutherford Appleton Laboratory

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…] Sent: 12 October 2007 13:11
To: Pascoe, S (Stephen)
Subject: Re: [Matplotlib-users] Basemap with origin within the plot

Pascoe, S (Stephen) wrote:

I am trying to prepare a plot on the UK national grid. This is a

transverse mercator projection centred on the UK with a false origin
offset from the projection origin (lat_0, lon_0).

The Basemap coordinate system origin (0 Easting and Northing) always

seems to be set in the lower-left corner of the plot. The plot I need
includes data either side of the origin so I need the origin within the
plot area.

Is there a general way of setting the origin somewhere other than the

lower-left corner?

I can either get basemap to plot the correct data region, in which

case the origin is in the wrong place or I can fool Basemap by adjusting
the axes bounds later. However, if I do this some of the coastline
isn't plotted because Basemap decides it isn't on the map.


Stephen: There's no way to change the coordinate system Basemap uses. To get you data to plot in the correct place, just add an offset

xoffset, yoffset = map(lon_0, lat_0)

to the UK national grid coordinates of the data you are plotting.



Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328