Last active
December 14, 2015 07:08
-
-
Save seumasmorrison/5048034 to your computer and use it in GitHub Desktop.
Example code and input data for Stack Overflow question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib.mlab import griddata | |
from matplotlib import cm | |
from matplotlib.ticker import LinearLocator, FormatStrFormatter | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import sys | |
def xyz_ret(file): | |
f = open(file, 'r') | |
xyz = [] | |
print "test" | |
for i in f: | |
ret = i.replace('\n','') | |
split_ret = ret.split(',') | |
xyz.append(map(float,(split_ret))) | |
xyz = np.array(xyz) | |
print xyz | |
return xyz[:,0],xyz[:,1],xyz[:,2] | |
x,y,z = xyz_ret('xyz.csv') | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
xi = np.linspace(min(x), max(x)) | |
yi = np.linspace(min(y), max(y)) | |
X, Y = np.meshgrid(xi, yi) | |
Z = griddata(x, y, z, xi, yi) | |
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, | |
linewidth=0) | |
plt.colorbar(surf, shrink=0.5, aspect=10) | |
ax.set_zlim3d(min(z), max(z)) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | 10.5 | 1 | |
---|---|---|---|
1 | 11.5 | 1 | |
1.5 | 12.5 | 1 | |
2 | 12.5 | 1 | |
2.5 | 13 | 1 | |
2.5 | 13.5 | 1 | |
3 | 13.5 | 1 | |
3.5 | 14 | 1 | |
4.5 | 7.5 | 1 | |
5 | 8 | 1 | |
5 | 14.5 | 1 | |
5.5 | 14.5 | 1 | |
6 | 13.5 | 1 | |
6 | 14.5 | 1 | |
6.5 | 14 | 1 | |
7.5 | 9.5 | 1 | |
7.5 | 14 | 1 | |
8 | 13 | 1 | |
8 | 14.5 | 1 | |
8.5 | 11 | 1 | |
9 | 11 | 1 | |
9 | 11.5 | 1 | |
9 | 12 | 1 | |
9 | 12.5 | 1 | |
9.5 | 11 | 1 | |
9.5 | 12.5 | 1 | |
9.5 | 14 | 1 | |
9.5 | 14.5 | 1 | |
10 | 11.5 | 1 | |
10 | 13 | 1 | |
10 | 14 | 1 | |
10 | 16.5 | 1 | |
10.5 | 15 | 1 | |
11 | 13 | 1 | |
11 | 13.5 | 1 | |
11.5 | 14 | 1 | |
12 | 15.5 | 1 | |
12.5 | 14 | 1 | |
13 | 17.5 | 1 | |
1 | 10 | 2 | |
1.5 | 11.5 | 2 | |
1.5 | 12 | 2 | |
2 | 13 | 2 | |
5.5 | 14 | 2 | |
6 | 13 | 2 | |
8 | 10.5 | 2 | |
8.5 | 13.5 | 2 | |
9 | 14.5 | 2 | |
9.5 | 11.5 | 2 | |
9.5 | 13.5 | 2 | |
10 | 12.5 | 2 | |
10.5 | 14.5 | 2 | |
1 | 9.5 | 3 | |
2 | 11.5 | 3 | |
3 | 6.5 | 3 | |
3 | 12.5 | 3 | |
3.5 | 13 | 3 | |
4 | 13.5 | 3 | |
4 | 14 | 3 | |
5.5 | 8.5 | 3 | |
5.5 | 13 | 3 | |
5.5 | 13.5 | 3 | |
6.5 | 9.5 | 3 | |
7.5 | 10.5 | 3 | |
7.5 | 13.5 | 3 | |
8 | 14 | 3 | |
8.5 | 14 | 3 | |
9 | 13.5 | 3 | |
9.5 | 15 | 3 | |
0.5 | 4.5 | 4 | |
2 | 12 | 4 | |
2.5 | 12.5 | 4 | |
3 | 13 | 4 | |
5 | 12.5 | 4 | |
5 | 13 | 4 | |
6.5 | 13 | 4 | |
7 | 10 | 4 | |
1.5 | 10.5 | 5 | |
3.5 | 13.5 | 5 | |
4 | 12 | 5 | |
4 | 12.5 | 5 | |
6 | 14 | 5 | |
8 | 11 | 5 | |
8.5 | 12 | 5 | |
8.5 | 13 | 5 | |
8.5 | 14.5 | 5 | |
9 | 13 | 5 | |
9 | 14 | 5 | |
3 | 12 | 6 | |
4.5 | 12.5 | 6 | |
8 | 13.5 | 6 | |
4 | 13 | 7 | |
5.5 | 9 | 7 | |
8 | 11.5 | 7 | |
0.5 | 8 | 8 | |
3.5 | 12 | 8 | |
4.5 | 12 | 8 | |
5 | 8.5 | 8 | |
5 | 13.5 | 8 | |
7.5 | 13 | 8 | |
8.5 | 11.5 | 8 | |
0.5 | 5 | 9 | |
0.5 | 5.5 | 9 | |
2.5 | 12 | 9 | |
3.5 | 12.5 | 9 | |
5 | 12 | 9 | |
6.5 | 10 | 9 | |
7.5 | 12.5 | 9 | |
8.5 | 12.5 | 9 | |
5.5 | 12.5 | 10 | |
7 | 13 | 10 | |
7.5 | 11.5 | 10 | |
8 | 12 | 10 | |
3 | 11.5 | 11 | |
3.5 | 7 | 11 | |
4 | 7.5 | 11 | |
6 | 12 | 11 | |
7.5 | 11 | 11 | |
4.5 | 8 | 12 | |
6 | 12.5 | 12 | |
1 | 4.5 | 13 | |
6 | 9.5 | 13 | |
7 | 10.5 | 13 | |
2 | 11 | 15 | |
7 | 12.5 | 15 | |
7.5 | 12 | 15 | |
6.5 | 12.5 | 16 | |
7 | 12 | 16 | |
8 | 12.5 | 16 | |
7 | 11.5 | 17 | |
0.5 | 6 | 18 | |
3.5 | 11.5 | 18 | |
5 | 11.5 | 18 | |
0.5 | 7 | 19 | |
1.5 | 10 | 19 | |
2.5 | 6 | 20 | |
5.5 | 9.5 | 20 | |
5.5 | 12 | 20 | |
0.5 | 7.5 | 21 | |
4 | 11.5 | 22 | |
6 | 10 | 22 | |
3.5 | 11 | 23 | |
5 | 9 | 23 | |
6.5 | 12 | 23 | |
7 | 11 | 23 | |
1.5 | 9.5 | 24 | |
4.5 | 8.5 | 24 | |
4.5 | 11.5 | 27 | |
0.5 | 6.5 | 28 | |
2.5 | 11.5 | 28 | |
2.5 | 11 | 29 | |
6.5 | 11.5 | 29 | |
1 | 8.5 | 30 | |
1 | 9 | 30 | |
5.5 | 11.5 | 30 | |
4 | 8 | 32 | |
4.5 | 11 | 32 | |
6 | 11.5 | 33 | |
6.5 | 11 | 33 | |
5 | 9.5 | 35 | |
6.5 | 10.5 | 36 | |
1.5 | 5 | 37 | |
2 | 10.5 | 38 | |
3 | 11 | 38 | |
3.5 | 7.5 | 40 | |
2.5 | 10.5 | 42 | |
4 | 11 | 42 | |
5 | 11 | 42 | |
1 | 8 | 43 | |
4 | 10.5 | 44 | |
3.5 | 10.5 | 45 | |
3 | 10.5 | 47 | |
5.5 | 10 | 49 | |
6 | 10.5 | 51 | |
6 | 11 | 52 | |
1.5 | 9 | 53 | |
2 | 5.5 | 55 | |
2.5 | 6.5 | 56 | |
4.5 | 9 | 56 | |
4 | 8.5 | 57 | |
5.5 | 11 | 58 | |
3 | 7 | 62 | |
4.5 | 10.5 | 63 | |
3 | 10 | 66 | |
5.5 | 10.5 | 66 | |
2 | 10 | 68 | |
2 | 9.5 | 71 | |
3.5 | 8 | 71 | |
5 | 10 | 71 | |
3.5 | 10 | 73 | |
1 | 5.5 | 74 | |
1 | 7.5 | 75 | |
1 | 5 | 79 | |
2 | 9 | 81 | |
2 | 6 | 89 | |
4.5 | 9.5 | 89 | |
2.5 | 9.5 | 90 | |
2.5 | 10 | 90 | |
3 | 8 | 90 | |
4.5 | 10 | 90 | |
5 | 10.5 | 93 | |
1.5 | 5.5 | 94 | |
1 | 7 | 99 | |
3 | 7.5 | 103 | |
4 | 10 | 105 | |
3.5 | 8.5 | 107 | |
4 | 9.5 | 120 | |
4 | 9 | 121 | |
3 | 9.5 | 128 | |
1.5 | 8.5 | 129 | |
3 | 8.5 | 131 | |
3 | 9 | 134 | |
2 | 6.5 | 136 | |
2.5 | 8.5 | 142 | |
3.5 | 9.5 | 146 | |
3.5 | 9 | 147 | |
2 | 8.5 | 151 | |
2.5 | 7 | 152 | |
1 | 6.5 | 154 | |
1.5 | 7.5 | 167 | |
2.5 | 9 | 168 | |
2.5 | 8 | 172 | |
1.5 | 6 | 173 | |
1.5 | 8 | 175 | |
1.5 | 7 | 200 | |
2 | 8 | 201 | |
2 | 7 | 204 | |
2 | 7.5 | 221 | |
1 | 6 | 222 | |
1.5 | 6.5 | 237 | |
2.5 | 7.5 | 246 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment