-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathverify_pressure.py
68 lines (52 loc) · 1.72 KB
/
verify_pressure.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from matplotlib import rc
rc('text', usetex=True)
import sys
import numpy as np
import os
import matplotlib.pyplot as plt
from pylab import *
def setAxLinesBW(ax):
"""
Take each Line2D in the axes, ax, and convert the line style to be
suitable for black and white viewing.
"""
MARKERSIZE = 3
COLORMAP = {
'b': {'marker': None, 'dash': (None,None)},
'g': {'marker': None, 'dash': [5,5]},
'r': {'marker': None, 'dash': [5,3,1,3]},
'c': {'marker': None, 'dash': [1,3]},
'm': {'marker': None, 'dash': [5,2,5,2,5,10]},
'y': {'marker': None, 'dash': [5,3,1,2,1,10]},
'k': {'marker': 'o', 'dash': (None,None)} #[1,2,1,10]}
}
for line in ax.get_lines():
origColor = line.get_color()
line.set_color('black')
line.set_dashes(COLORMAP[origColor]['dash'])
line.set_marker(COLORMAP[origColor]['marker'])
line.set_markersize(MARKERSIZE)
def setFigLinesBW(fig):
"""
Take each axes in the figure, and for each line in the axes, make the
line viewable in black and white.
"""
for ax in fig.get_axes():
setAxLinesBW(ax)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.set_yscale('log')
for fname in sys.argv[1:]:
with open(fname, 'r') as infile:
data = np.genfromtxt(infile, delimiter=',')
time = data[:,0] / 1.0e-6
radius = data[:,3]
label_name = os.path.splitext(fname)[0]
label_name = label_name.replace('_', ' ')
label_name = label_name.replace('%', '\\%')
ax.plot(time, radius, label=label_name)
ax.set_xlabel("Time ($\\mu$s)")
ax.set_ylabel("Pressure (Pa)")
setFigLinesBW(fig)
ax.legend(bbox_to_anchor=(0.75, 1.00), loc=2, borderaxespad=0.0)
plt.show()