In [1]:
%pylab inline
In [2]:
import csv
In [3]:
csvfile = open('results_and_cart.csv', 'r')
spamreader = csv.reader(csvfile, delimiter=';')
In [4]:
X = list()
Y = list()
Z = list()
for row in spamreader:
X.append(row[2])
Y.append(row[1])
Z.append(row[4])
print(X, Y, Z)
# Un point n'a pas de valeur, on l'enleve
X.pop(3)
Y.pop(3)
Z.pop(3)
Out[4]:
In [5]:
x = array([float(v) for v in X])
y = array([float(v) for v in Y])
z = array([float(v) for v in Z])
print(x.min(), x.max())
print(y.min(), y.max())
print(z.min(), z.max())
In [6]:
x_min = 5.88
x_max = 6.02
delta_x = (x_max - x_min) / 100
gx = np.arange(x_min, x_max, delta_x)
y_min = 43.06
y_max = 43.13
delta_y = (y_max - y_min) / 100
gy = np.arange(y_min, y_max, delta_y)
X, Y = np.meshgrid(gx, gy)
In [7]:
fig = figure(figsize=(24,12))
Z = griddata(x, y, z, X, Y, interp='nn')
from matplotlib.ticker import MaxNLocator
levels = MaxNLocator(nbins=15).tick_values(z.min(), z.max())
contour(X, Y, Z, levels=levels, colors='black', linewidth=2)
contourf(X, Y, Z, levels=levels)
#, cmap=cmap)
colorbar()
scatter(x, y)
Out[7]:
In [8]:
fig.savefig('resultats_contour.png', format='png')
In [9]:
X
Out[9]:
In [10]:
Z
Out[10]:
In [11]:
Z[20,:]
Out[11]: