<comment>## Note: example as seen on matplotlib webpage (2013-08-26):</comment> <comment>## - http://matplotlib.org/examples/pylab_examples/griddata_demo.html</comment> <comment>## Only adapted color handling</comment> <comment>## Loading necessary python modules for this example</comment> `from numpy.random import uniform, seed` `from matplotlib.mlab import griddata` `import matplotlib.pyplot as plt` `import numpy as np` <comment>## make up data.</comment> `seed(0)` `npts = 200` `x = uniform(-2,2,npts)` `y = uniform(-2,2,npts)` `z = x*np.exp(-x**2-y**2)` <comment>## define grid.</comment> `xi = np.linspace(-2.1,2.1,100)` `yi = np.linspace(-2.1,2.1,200)` <comment>## grid the data.</comment> `zi = griddata(x,y,z,xi,yi,interp='linear')` <comment>## contour the gridded data, plotting dots at the nonuniform data points. `CS = plt.contour(xi,yi,zi,len(colors)-1,linewidths=0.5,colors='k')` `CS = plt.contourf(xi,yi,zi,len(colors)-1,colors=colors,` `vmax=abs(zi).max(), vmin=-abs(zi).max())` `plt.colorbar() # draw colorbar` <comment>## plot data points.</comment> `plt.scatter(x,y,marker='o',c='b',s=5,zorder=10)` `plt.xlim(-2,2)` `plt.ylim(-2,2)` `plt.title('griddata test (%d points)' % npts)` `plt.show()`