-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplot_uvec.py
More file actions
34 lines (25 loc) · 849 Bytes
/
plot_uvec.py
File metadata and controls
34 lines (25 loc) · 849 Bytes
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
import matplotlib.pyplot as plt
import numpy as np
import pymod_uvec as uvec
var_name = ["1x", "1y", "1z", "2x", "2y", "2z", "3x", "3y", "3z"]
file_name = ["res/kuvl.dat", "res/euvl.dat"]
color = ['k', 'b', 'g', 'm']
n_file = len( file_name )
ax = uvec.create()
def plot_vector( s1, s2, s3, i ):
x, y, z = dat[s1], dat[s2], dat[s3]
a = uvec.Arrow3D( [0, x], [0, y], [0, z],
mutation_scale=20, lw=1, arrowstyle="-|>",
color=color[i] )
ax.add_artist(a)
ax.text(x, y, z, "%c"%(s1[0]))
for i in range(n_file):
data = np.loadtxt( file_name[i] )
dat = dict( (k, v) for (k, v) in zip( var_name, data ) )
plot_vector( "3x", "3y", "3z", i )
plot_vector( "2x", "2y", "2z", i )
plot_vector( "1x", "1y", "1z", i )
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()