My aim is to plot some data and merge it with the world map. I produce data using Delaunay triangulation, like this:
u = np.array(lat)
v = np.array(lon)
x = u
y = v
z = np.array(iwv)
tri = Delaunay(np.array([u,v]).T)
plt.tricontourf(y, x, z, lev, triangles=tri.simplices)
plt.colorbar()
plt.show()
I also make a map using mpl_toolkits:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
m = Basemap(projection='merc',llcrnrlat= 35,urcrnrlat=60,llcrnrlon=0,urcrnrlon=30,resolution='c', suppress_ticks=True)
m.drawcountries()
m.drawcoastlines()
plt.show()
These procedures give me two consequtive separated pictures with the results of triangulation and the map. How can I merge them and get picture with both map and result of triangulation? Thank you in advance.
To armatita. Thank you for your answer, but it doesn't help. When I run this code:
u = np.array(lat)
v = np.array(lon)
x = u
y = v
z = np.array(iwv)
tri = Delaunay(np.array([u,v]).T)
lev = np.linspace(0, 0.1, 100)
m = Basemap(projection='merc',llcrnrlat= 35,urcrnrlat=60,llcrnrlon=0,urcrnrlon=30,resolution='c', suppress_ticks=True)
m.drawcountries()
m.drawcoastlines()
plt.tricontourf(y, x, z, lev, triangles=tri.simplices)
plt.colorbar()
plt.show()
I get just an empty map with color bar.
To dl.meteo: Thank you, but when I'm trying to do that, I get the next message:
> Traceback (most recent call last): File
> "/home/anton/PycharmProjects/final/test.py", line 76, in <module>
> plot = m.contourf(x1, y1,z, lev) File "/usr/lib/pymodules/python2.7/mpl_toolkits/basemap/__init__.py", line
> 521, in with_transform
> return plotfunc(self,x,y,data,*args,**kwargs) File "/usr/lib/pymodules/python2.7/mpl_toolkits/basemap/__init__.py", line
> 3644, in contourf
> xx = x[x.shape[0]/2,:] IndexError: too many indices
As I understand, the third argument in contourf() should be a 2D-array, but triangulation returns 1D-array.