EVOLUTION-MANAGER
Edit File: python-example.html
<div style="height: 2em;"></div> <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> <code>from numpy.random import uniform, seed</code> <code>from matplotlib.mlab import griddata</code> <code>import matplotlib.pyplot as plt</code> <code>import numpy as np</code> <comment>## make up data.</comment> <code>seed(0)</code> <code>npts = 200</code> <code>x = uniform(-2,2,npts)</code> <code>y = uniform(-2,2,npts)</code> <code>z = x*np.exp(-x**2-y**2)</code> <comment>## define grid.</comment> <code>xi = np.linspace(-2.1,2.1,100)</code> <code>yi = np.linspace(-2.1,2.1,200)</code> <comment>## grid the data.</comment> <code>zi = griddata(x,y,z,xi,yi,interp='linear')</code> <comment>## contour the gridded data, plotting dots at the nonuniform data points. <code>CS = plt.contour(xi,yi,zi,len(colors)-1,linewidths=0.5,colors='k')</code> <code>CS = plt.contourf(xi,yi,zi,len(colors)-1,colors=colors,</code> <code> vmax=abs(zi).max(), vmin=-abs(zi).max())</code> <code>plt.colorbar() # draw colorbar</code> <comment>## plot data points.</comment> <code>plt.scatter(x,y,marker='o',c='b',s=5,zorder=10)</code> <code>plt.xlim(-2,2)</code> <code>plt.ylim(-2,2)</code> <code>plt.title('griddata test (%d points)' % npts)</code> <code>plt.show()</code>