I have regular mesh which I want to draw. I used plot_surface, but the result is a bit strange. Could you help with drawing? I've tried to change limit for axes but it didn't help. May be you could suggest better way for drawing points as surface. Thanks!
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
from array import *
x = np.array([0, 0, 0, 400, 400, 400, 800, 800, 800])
y = np.array([0, 400, 800, 0, 400, 800, 0, 400, 800])
z = np.array([10.0, 10.0, 10.0, 10.0, 206.8, 10.0, 10.0, 10.0, 10.0])
#print len(x), len(y), len(z)
zdict = {}
for i in range (0, len(x)):
#print "(", x[i], ", ", y[i], "): ", z[i], ", "
zdict[(x[i], y[i])] = z[i]
print zdict
def zfunc(x, y):
return zdict[(x, y)]
X, Y = np.meshgrid(x, y)
print X, Y
#need 2d array of Z
Z = [[zfunc(X[i][j], Y[i][j]) for i in range(0, len(X))] for j in range(0, len(X[0]))]
print Z
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim(0, 300.0)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()