이는) 데이터가 균등하게 그리드에 있다고 가정하고 b) 사용자가 그리드의 모든이
from pylab import * # mostly to make my fake data work
import copy
# make some fake data
X, Y = np.meshgrid(range(10), range(10))
xyz = zip(X.flat, Y.flat, np.random.rand(100)) # make sure you have a list of tuples
xyz_org = copy.copy(xyz)
# randomize the tuples
shuffle(xyz)
# check we changed the order
assert xyz != xyz_org
# re-sort them
xyz.sort(key=lambda x: x[-2::-1]) # sort only on the first two entries
# check we did it right
assert xyz == xyz_org
# extract the points and re-shape to a grid
X_n, Y_n, z = [np.array(_).reshape(10, 10) for _ in zip(*xyz)]
# check we re-created X and Y correctly
assert np.all(X_n == X)
assert np.all(Y_n == Y)
# make the plot
plt.contour(X_n, Y_n, z)
포인트