Plotting Data with Basemap

189 views Asked by At

I am trying to plot the following dataset using a Basemap instance:

[-0.126929 -0.127279 -0.127851 ..., -0.14199 -0.142828 -0.14335 ]

The problem is I can't have the right number of points displayed on the map. (which is the length of my data list above = 1315 points).

If I define my dataset to be like:

data = np.diag(data)

[[-0.126929 0. 0. ..., 0. 0. 0. ] [ 0. -0.127279 0. ..., 0. 0. 0. ] [ 0. 0. -0.127851 ..., 0. 0. 0. ] ..., [ 0. 0. 0. ..., -0.14199 0. 0. ] [ 0. 0. 0. ..., 0. -0.142828 0. ] [ 0. 0. 0. ..., 0. 0. -0.14335 ]]

I have this figure enter image description here

If I define my dataset to be like:

data = np.ma.masked_where(data==0., data)

[[-0.12692899999999696 -- -- ..., -- -- --] [-- -0.12727900000000147 -- ..., -- -- --] [-- -- -0.12785099999999971 ..., -- -- --] ..., [-- -- -- ..., -0.14198999999999984 -- --] [-- -- -- ..., -- -0.1428280000000015 --] [-- -- -- ..., -- -- -0.1433499999999981]]

I have this figure enter image description here

fig = plt.figure()     

m = Basemap(projection='mill',      \
            llcrnrlon= lonmin-0.02, \
            urcrnrlon= lonmax+0.02, \
            llcrnrlat= latmin-0.02, \
            urcrnrlat= latmax+0.02, \
            resolution='f')     

cmap = plt.cm.get_cmap('bwr_r')

x, y = m(*np.meshgrid(lon,lat))
y = y.T 
cs = m.contourf(x,y,data,cmap=cmap)

m.drawcoastlines(linewidth=1.,color='grey')
m.drawcountries(linewidth=1.5,color='white')
m.drawmapboundary(color='k',linewidth=2.0)
m.fillcontinents(color='white')           

cb = m.colorbar(cs,location='bottom',size='5%',pad='8%')
cb.set_label('[m]',fontsize=12)
plt.show() 
0

There are 0 answers