In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
import csv
In [48]:
ld = [ 1., 1.]
WIDTH = 640
HEIGHT = 640
print WIDTH*HEIGHT
hd = [ld[0]/(float(WIDTH)), ld[1]/(float(HEIGHT)) ]
In [15]:
with open('sinsin2dtex_result.csv','r') as csvfile_result:
plot_results = csv.reader(csvfile_result, delimiter=',')
result_list = list( list(rec) for rec in plot_results )
with open('sinsin2dtex_ogref.csv','r') as csvfile_ogref:
plot_ogref = csv.reader(csvfile_ogref, delimiter=',')
ogref_list = list( list(rec) for rec in plot_ogref )
In [16]:
csvfile_result.close()
csvfile_ogref.close()
In [21]:
result_list = [[float(ele) for ele in row] for row in result_list]
ogref_list = [[float(ele) for ele in row] for row in ogref_list]
In [25]:
# sanity check
print len(result_list); print len(result_list[0]);
print result_list[ len(result_list)/4][ len(result_list[0])/4 : len(result_list[0])/4+22];
print len(ogref_list); print len(ogref_list[0]);
print ogref_list[ len(ogref_list)/4][ len(ogref_list[0])/4 : len(ogref_list[0])/4+22]
In [26]:
from mpl_toolkits.mplot3d import axes3d
import numpy as np
In [27]:
fig = plt.figure()
In [29]:
ax = fig.add_subplot(111,projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
In [30]:
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
Out[30]:
In [31]:
plt.show()
In [32]:
fig
Out[32]:
In [41]:
print type(X), type(Y), type(Z); print len(X), len(Y), len(Z); print X.shape, Y.shape, Z.shape;
In [43]:
X
Out[43]:
In [44]:
Y
Out[44]:
In [45]:
Z
Out[45]:
In [46]:
X[0][0:10]
Out[46]:
EY : At least what I could surmise or infer the 2-dim. (???) python arrays for X,Y,Z
of the wireframe plot work like this: imagine a 2-dimensional grid; on top of each grid point is the x-coordinate, then the y-coordinate, and then the z-coordinate. Thus you have 2-dimensional arrays for each.
In [55]:
X_sinsin = np.array( [[i*hd[0] for i in range(WIDTH)] for j in range(HEIGHT)] )
Y_sinsin = np.array( [[j*hd[1] for i in range(WIDTH)] for j in range(HEIGHT)] )
Z_sinsinresult = np.array( [[result_list[i][j] for i in range(WIDTH)] for j in range(HEIGHT)] )
Z_sinsinogref = np.array( [[ogref_list[i][j] for i in range(WIDTH)] for j in range(HEIGHT)] )
In [56]:
fig02 = plt.figure()
ax02 = fig02.add_subplot(111,projection='3d')
ax02.plot_wireframe(X_sinsin, Y_sinsin, Z_sinsinresult )
Out[56]:
In [57]:
plt.show()
In [59]:
fig02
Out[59]:
In [60]:
fig03 = plt.figure()
ax03 = fig03.add_subplot(111,projection='3d')
ax03.plot_wireframe(X_sinsin, Y_sinsin, Z_sinsinogref )
Out[60]:
In [61]:
plt.show()
In [62]:
fig03
Out[62]:
In [ ]: