-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplotlib.py
More file actions
86 lines (71 loc) · 2.51 KB
/
matplotlib.py
File metadata and controls
86 lines (71 loc) · 2.51 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
"""
@author: Steinn Ymir Agustsson
"""
import matplotlib.pyplot as plt
def main():
pass
def set_style(large_style=True):
plt.style.use('seaborn-white')
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = 'Arial'
plt.rcParams['font.monospace'] = 'Arial'
plt.rcParams['font.size'] = 10
plt.rcParams['axes.labelsize'] = 20
plt.rcParams['axes.labelweight'] = 'bold'
plt.rcParams['axes.titlesize'] = 20
plt.rcParams['xtick.labelsize'] = 8
plt.rcParams['ytick.labelsize'] = 8
plt.rcParams['legend.fontsize'] = 10
plt.rcParams['figure.titlesize'] = 12
def plot_lines(data, normalization='None', range=None, color_range=(0,1),
x_label='',y_label='', xlim=None, ylim=None,
savefig=False, save_dir='E:/data/FLASH/', save_name='fig', static_curve=None):
"""
:param data:
:param normalization:
:param range:
:param color_range:
:return:
"""
f, axis = plt.subplots(1, 1, figsize=(8, 6), sharex=True)
if range is None:
from_ = 0
to_= len(data[:,...])
else:
from_ = range[0]
to_ = range[1]
n_curves = len(data[from_:to_,0])
print(n_curves)
cm_subsection = np.linspace(color_range[0], color_range[1], n_curves)
colors = [cm.coolwarm(1 - x) for x in cm_subsection]
for i, color in enumerate(colors[from_:to_]):
label = '{}'.format(i) # 20*(i+from_),
curve = data[i + from_, :] # result_unpumped[i]
if normalization == 'sum':
curve /= curve.sum()
elif normalization == 'max':
curve /= curve.max()
axis.plot(curve, '-', color=color, label=label)
# axis[1].plot(x_axis_energy,curve_pump, '-', color=color,label=label)
if static_curve is not None:
plt.plot(static_curve, '--', color='black', label='static')
plt.grid()
plt.legend(fontsize='large')
plt.xlabel(x_label, fontsize='xx-large')
plt.ylabel(y_label, fontsize='xx-large')
plt.xticks(fontsize='large')
plt.yticks(fontsize='large')
if xlim is not None:
plt.xlim(xlim[0],xlim[1])
if ylim is not None:
plt.ylim(ylim[0],ylim[1])
if savefig:
plt.savefig('{}{}.png'.format(save_dir,save_name), dpi=200, facecolor='w',
edgecolor='w',
orientation='portrait', papertype=None, format=None,
transparent=True, bbox_inches=None, pad_inches=0.1,
frameon=None)
plt.show()
if __name__ == '__main__':
main()