-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdraw_band3.combine.py
95 lines (75 loc) · 2.6 KB
/
draw_band3.combine.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import numpy as np
import sys
import matplotlib.pyplot as plt
SMALL_SIZE = 12
MEDIUM_SIZE = 14
BIGGER_SIZE = 16
plt.rc('font', size=BIGGER_SIZE) # controls default text sizes
plt.rc('axes', titlesize=BIGGER_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
fig = plt.figure()
ax = fig.add_subplot(111)
# load data
if len(sys.argv) < 2:
print('Error! Enter the folders')
sys.exit()
print('Will plot the BS data in .npz file.')
folders = sys.argv[1:]
filename = 'bs_numpy.npz'
fileinfo1 = 'SAVEINFO'
colors = ['tomato','royalblue','tab:green','gold']
colors = colors[:len(folders)]
colors = colors[::-1]
# draw phonon dispersion
for i,f_i in enumerate(folders):
data=np.load(f_i + '/' + filename,allow_pickle=True) # this one works for data with several columns.
info1=np.loadtxt(f_i + '/' + fileinfo1, comments='#',dtype=str, delimiter='=') # this one works for data with several columns.
info1=dict(info1)
x=data['x']
y=data['y']
plt.plot(x,y[:,:-1],color=colors[i])
plt.plot(x,y[:,-1],color=colors[i],label=info1['legend'])
# ticks should be the same
print('ticks are from %s' % f_i )
ticks=data['ticks']
tick_position=ticks.item()['distance']
tick_label=ticks.item()['label']
# draw the separations q-points
for tick in tick_position:
plt.axvline(x=tick,c ='grey',ls='--')
plt.axhline(y=0,c ='grey',ls='--')
plt.xticks(tick_position,tick_label)
#####################################################################
labeltype=0 # no labels
# save your often used labels
#####################################################################
# edit lables
#####################################################################
if labeltype == 0:
#plt.legend()
plt.legend(loc='upper right')
title='Band Structure'
xlabel=''
xlabelunit=' '
ylabel='Energy'
ylabelunit=' (eV)'
#####################################################################
#leg = ax.get_legend()
#for i in range(len(folders)):
# leg.legendHandles[i].set_linestyle('--')
plt.xlim([min(x),max(x)])
plt.title(title) # add title
plt.xlabel(xlabel+xlabelunit) # x label
plt.ylabel(ylabel+ylabelunit) # y label
plt.tight_layout()
plt.ylim([-1, 1])
figname= 'bs_combine.pdf'
print('\tfigure saved as \n%s' % (figname))
#plt.savefig(figname,dpi=600)
plt.savefig(figname)
plt.show()
plt.close()