-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplotter.py
More file actions
53 lines (37 loc) · 1.16 KB
/
plotter.py
File metadata and controls
53 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
def drange(start, n, step):
result = float(start)
for i in xrange(0, int(n)):
yield result
result += float(step)
def readDataFromFile():
return [line.strip().split() for line in open('data/result.dat')]
def getDataFromFile():
lines = readDataFromFile()
xs = list(drange(lines[0][0], lines[0][1], lines[0][2]))
ts = list(drange(lines[1][0], lines[1][1], lines[1][2]))
Ui = []
for ind in xrange(2, len(lines)):
line = [float(i) for i in lines[ind]]
Ui.append(line)
realXs, realTs, realUis = [], [], []
for x in xrange(0, len(xs)):
for t in xrange(0, len(ts)):
realXs.append(xs[x])
realTs.append(ts[t])
realUis.append(Ui[t][x])
return realXs, realTs, realUis
fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
ax = fig.gca(projection='3d')
xs, ts, Ui = getDataFromFile()
ax.plot_trisurf(xs, ts, Ui, linewidth=0.01, cmap=cm.jet)
# ax.scatter(xs, ts, Ui, c='r', marker='o')
# ax.set_xlabel('x')
# ax.set_ylabel('t')
# ax.set_zlabel('U`')
plt.show()