irregular grid in python interpolation code example
Example: irregular grid in python interpolation
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.tri as tri
import pandas as pd
data = pd.read_csv('sample.csv',delim_whitespace=True)
data.columns = ['x','y']
x = data['x']
y = data['y']
x = np.array(x)
y = np.array(y)
xi = np.linspace(-10.0,10.0,2500)
yi = np.linspace(-10.0,10.0,2500)
zi = mlab.griddata(x,y,z,xi,yi,interp='linear')
X,Y = np.meshgrid(xi,yi)
Z = zi
h1 = np.min(Z)
h2 = np.max(Z)
plt.contourf(X,Y,Z,255,norm=plt.Normalize(h1,h2),cmap=plt.cm.jet)
plt.show()