Hi all,

Indeed it's a bit strange, I can reproduce the problem. But when using
'cyl' projection I don't have this issue.
attahced two figures showed the difference.

the tested data is also attached.

complete code is below:

from mpl_toolkits.basemap import Basemap, cm, maskoceans
import matplotlib.pyplot as plt


# set up the Mercator projection
m = Basemap(projection='merc',llcrnrlat=9,urcrnrlat=54.5,\
            llcrnrlon=74,urcrnrlon=142,lat_ts=20,resolution='l')

m.drawcountries()
m.drawcoastlines()
m.drawmapboundary(fill_color='aqua')
m.drawrivers()

pdata = np.genfromtxt('pdata.txt')
pdata = np.ma.masked_greater(pdata,1E20)
lonm,latm=m.makegrid(pdata.shape[1],pdata.shape[0])

latm=np.flipud(latm)
lonpro,latpro=m(lonm,latm)
cs = m.contourf(lonpro,latpro,pdata)
m.colorbar(cs)

cheers,

Chao

On Mon, Apr 29, 2013 at 12:53 PM, Ann [via matplotlib] <
ml-node+s1069221n40973...@n5.nabble.com> wrote:

> Dear All,
>
>
> I am encountering the following problem:
> I have some data which I want to plot on a map. Unfortunately, I do not
> manage to plot the data according to the shape of the projection! What it
> appears to do is to simply plot the data on top of the projection without
> taking the actual position (latitude and longitude) into account. However,
> this is crucial for my analysis.
> Could anybody spot the mistake in my code?
> Any suggestion would be of great help!!
> THANKS
>
>
>
> from mpl_toolkits.basemap import Basemap, cm, maskoceans
> import matplotlib.pyplot as plt
>
>
> # set up the Mercator projection
> m = Basemap(projection='merc',llcrnrlat=9,urcrnrlat=54.5,\
>             llcrnrlon=74,urcrnrlon=142,lat_ts=20,resolution='l')
>
> m.drawcountries()
> m.drawcoastlines()
> m.drawmapboundary(fill_color='aqua')
> m.drawrivers()
>
>
> parallels = N.arange(0.,81,10.)
> labels = [left,right,top,bottom]
> m.drawparallels(parallels,labels=[1,0,0,0])
> meridians = N.arange(10.,351.,20.)
> m.drawmeridians(meridians,labels=[0,0,0,1])
>
>
> ny=resmat.shape[0] # resmat is the matrix containing the data which I want
> o plot.
> nx=resmat.shape[1]
>
> #get lat/lons of ny by nx evenly space grid
> lons, lats =m.makegrid(nx, ny)
>
>
> # compute map projection coordinates
> x, y= m(lons, lats)
>
> maskdata = maskoceans(lons, lats, resmat, inlands= True, resolution = 'l')
>
>
> cs = m.contourf(x,y,maskdata,150,cmap=cm.GMT_no_green_r)
>
> plt.show()
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://matplotlib.1069221.n5.nabble.com/Basemap-plotting-data-on-projection-tp40973.html
>  To start a new topic under matplotlib - users, email
> ml-node+s1069221n...@n5.nabble.com
> To unsubscribe from matplotlib, click 
> here<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx>
> .
> NAML<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************


pdata.txt (413K) 
<http://matplotlib.1069221.n5.nabble.com/attachment/40975/0/pdata.txt>
cyl.jpg (540K) 
<http://matplotlib.1069221.n5.nabble.com/attachment/40975/1/cyl.jpg>
merc.jpg (435K) 
<http://matplotlib.1069221.n5.nabble.com/attachment/40975/2/merc.jpg>




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Basemap-plotting-data-on-projection-tp40973p40975.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to