-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvizualization2.py
More file actions
53 lines (42 loc) · 1.29 KB
/
vizualization2.py
File metadata and controls
53 lines (42 loc) · 1.29 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
53
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
import ast
with open('mainFunc.txt', 'r') as file:
for string in file:
data = ast.literal_eval(string.strip())
fig = plt.figure()
ax = fig.gca(projection='3d')
X_LEFT_BOUND = np.float64(data[0][0])
X_RIGHT_BOUND = np.float64(data[0][1])
H_num = np.float64(data[0][2])
X_LIN = np.linspace(X_LEFT_BOUND, X_RIGHT_BOUND, H_num)
TIME_LEFT_BOUND = np.float64(data[1][0])
TIME_RIGHT_BOUND = np.float64(data[1][1])
Time_layers_num = np.float64(data[1][2])
Y_LIN = np.linspace(TIME_LEFT_BOUND, TIME_RIGHT_BOUND, Time_layers_num)
# Make data.
X = X_LIN
Y = Y_LIN
print(Y.shape)
print(X)
print(Y.shape)
Z = np.array(data[2])
print(Z.shape)
X, Y = np.meshgrid(X, Y)
print(X.shape)
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
linewidth=1, antialiased=False)
# Customize the z axis.
ax.set_zlim(1.01, 5.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)
ax.set_xlabel('X')
ax.set_ylabel('Time')
ax.set_zlabel('Temperature')
plt.show()