bandplot 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bandplot might be problematic. Click here for more details.

@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.1
2
+ Name: bandplot
3
+ Version: 0.1.1
4
+ Summary: bandplot: band structure plot from vaspkit result.
5
+ Home-page: https://github.com/lkccrr/bandplot
6
+ Author: kan
7
+ Author-email: luokan@hrbeu.edu.cn
8
+ License: MIT
9
+ Description: .. image:: https://img.shields.io/pypi/v/pbandplot.svg
10
+ :target: https://pypi.org/project/pbandplot/
11
+
12
+ .. image:: https://img.shields.io/pypi/pyversions/pbandplot.svg
13
+ :target: https://pypi.org/project/pbandplot/
14
+
15
+ pbandplot
16
+ =========
17
+
18
+ pbandplot: Plot the phonon band structure plot from phonopy result.
19
+
20
+ * To execute ``pbandplot -h`` for the parameters to use.
21
+ * Example::
22
+
23
+ pbandplot -i band.dat -o pband.png -l g m k g -d projected_dos.dat
24
+ pbandplot -b 23 100 -l g m k g -y -2 110
25
+
26
+
27
+ Keywords: VASP band structure plot
28
+ Platform: Unix
29
+ Platform: Windows
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Programming Language :: Python
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3 :: Only
34
+ Classifier: Programming Language :: Python :: 3.6
35
+ Classifier: Programming Language :: Python :: 3.7
36
+ Classifier: Programming Language :: Python :: 3.8
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Requires-Python: >=3.6
41
+ Description-Content-Type: text/x-rst
@@ -0,0 +1,17 @@
1
+ .. image:: https://img.shields.io/pypi/v/pbandplot.svg
2
+ :target: https://pypi.org/project/pbandplot/
3
+
4
+ .. image:: https://img.shields.io/pypi/pyversions/pbandplot.svg
5
+ :target: https://pypi.org/project/pbandplot/
6
+
7
+ pbandplot
8
+ =========
9
+
10
+ pbandplot: Plot the phonon band structure plot from phonopy result.
11
+
12
+ * To execute ``pbandplot -h`` for the parameters to use.
13
+ * Example::
14
+
15
+ pbandplot -i band.dat -o pband.png -l g m k g -d projected_dos.dat
16
+ pbandplot -b 23 100 -l g m k g -y -2 110
17
+
@@ -1 +1,4 @@
1
1
  from bandplot.wrapper import main
2
+
3
+ __version__ = "0.1.1"
4
+
@@ -0,0 +1,267 @@
1
+ import matplotlib.pyplot as plt
2
+
3
+ def Noneispin(EXPORT, figsize, vertical, arr, bands, ticks, labels, linestyle, legend, location, color):
4
+ plt.figure(figsize=figsize)
5
+ if len(color) == 0:
6
+ color = ['r']
7
+
8
+ plt.plot(arr, bands.T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
9
+ plt.tick_params(axis='y', which='minor', color='gray')
10
+
11
+ plt.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
12
+ if len(ticks) > 2:
13
+ ticks[0],ticks[-1] = arr[0],arr[-1]
14
+ for i in ticks[1:-1]:
15
+ plt.axvline(i, linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
16
+
17
+ plt.xticks(ticks,labels)
18
+ plt.legend(legend, frameon=False, prop={'size':'medium'}, loc=location)
19
+ plt.xlim(arr[0], arr[-1])
20
+ plt.ylim(vertical)
21
+ plt.ylabel('Energy (eV)')
22
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
23
+
24
+ def Ispin(EXPORT, figsize, vertical, arr, bands, ticks, labels, linestyle, legend, location, color):
25
+ plt.figure(figsize=figsize)
26
+ if len(color) < 2:
27
+ color = ['r', 'k']
28
+
29
+ if len(linestyle) < 2:
30
+ linestyle = ['-', '-.']
31
+
32
+ p_up = plt.plot(arr, bands[0].T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
33
+ p_do = plt.plot(arr, bands[1].T, color=color[1], linewidth=0.8, linestyle=linestyle[1])
34
+ plt.legend([p_up[0], p_do[0]], ['up', 'down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc=location, title=legend[0], title_fontproperties={'size':'medium'})
35
+ plt.tick_params(axis='y', which='minor', color='gray')
36
+ plt.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
37
+ if len(ticks) > 2:
38
+ ticks[0],ticks[-1] = arr[0],arr[-1]
39
+ for i in ticks[1:-1]:
40
+ plt.axvline(i, linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
41
+
42
+ plt.xlim(arr[0], arr[-1])
43
+ plt.ylim(vertical)
44
+ plt.xticks(ticks,labels)
45
+ plt.ylabel('Energy (eV)')
46
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
47
+
48
+ def Dispin(EXPORT, figsize, vertical, arr, bands, ticks, labels, linestyle, legend, location, color):
49
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=figsize)
50
+ fig.subplots_adjust(wspace=0.0)
51
+ if len(color) < 2:
52
+ color = ['r', 'k']
53
+
54
+ if len(linestyle) < 2:
55
+ linestyle = ['-', '-.']
56
+
57
+ ax1.plot(arr, bands[0].T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
58
+ ax2.plot(arr, bands[1].T, color=color[1], linewidth=0.8, linestyle=linestyle[1])
59
+ ax1.legend(['up'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc=location, title=legend[0], title_fontproperties={'size':'medium'})
60
+ ax2.legend(['down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc=location)
61
+ ax1.tick_params(axis='y', which='minor', color='gray')
62
+ ax2.tick_params(axis='y', which='minor', color='gray')
63
+
64
+ ax1.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
65
+ ax2.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
66
+ ax2.set_yticklabels([])
67
+ if len(ticks) > 2:
68
+ ticks[0],ticks[-1] = arr[0],arr[-1]
69
+ for i in ticks[1:-1]:
70
+ ax1.axvline(i, linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
71
+ ax2.axvline(i, linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
72
+
73
+ ax1.set_xlim(arr[0], arr[-1])
74
+ ax1.set_ylim(vertical)
75
+ ax2.set_xlim(arr[0], arr[-1])
76
+ ax2.set_ylim(vertical)
77
+ ax1.set_xticks(ticks,labels[:-1]+[''])
78
+ ax2.set_xticks(ticks,labels)
79
+ ax1.set_ylabel('Energy (eV)')
80
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
81
+
82
+ def NoneispinWd(EXPORT, figsize, vertical, horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, location, color):
83
+ fig, (ax1, ax2) = plt.subplots(1, 2, width_ratios=[1-width_ratios, width_ratios], figsize=figsize)
84
+ fig.subplots_adjust(wspace=0.0)
85
+ if len(color) == 0:
86
+ color = ['r']
87
+
88
+ ax1.plot(arr, bands.T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
89
+ num = len(index_f)
90
+ if num + 1 > len(color):
91
+ color = color + [''] * (num + 1 - len(color))
92
+
93
+ if num + 1 > len(linestyle):
94
+ linestyle = linestyle + ['-'] * (num + 1 - len(linestyle))
95
+
96
+ for i in range(num):
97
+ if color[i+1]:
98
+ ax2.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+1], color=color[i+1])
99
+ else:
100
+ ax2.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+1])
101
+
102
+ ax1.legend(legend, frameon=False, prop={'size':'small'}, loc=location)
103
+ ax1.tick_params(axis='y', which='minor', color='gray')
104
+ ax2.minorticks_on()
105
+ ax2.tick_params(axis='both', which='minor', color='gray')
106
+ ax2.set_yticklabels([])
107
+ ax2.legend(elements, frameon=False, prop={'size':'small'}, alignment='left', loc=location, title="Density of states", title_fontproperties={'size':'small'})
108
+ ax1.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
109
+ ax2.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
110
+ ax2.axvline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
111
+ if len(ticks) > 2:
112
+ ticks[0],ticks[-1] = arr[0],arr[-1]
113
+ for i in ticks[1:-1]:
114
+ ax1.axvline(i,linewidth=0.5,linestyle=(0, (3, 2, 1, 2, 1, 2)),c='gray')
115
+
116
+ ax1.set_xlim(arr[0], arr[-1])
117
+ ax1.set_ylim(vertical)
118
+ ax2.set_xlim(horizontal)
119
+ ax2.set_ylim(vertical)
120
+ ax1.set_xticks(ticks,labels)
121
+ ax2.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
122
+ ax1.set_ylabel('Energy (eV)')
123
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
124
+
125
+ def IspinWd(EXPORT, figsize, vertical, horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, location, color):
126
+ fig, (ax1, ax2) = plt.subplots(1, 2, width_ratios=[1-width_ratios, width_ratios], figsize=figsize)
127
+ fig.subplots_adjust(wspace=0.0)
128
+ if len(color) < 2:
129
+ color = ['r', 'k']
130
+
131
+ if len(linestyle) < 2:
132
+ linestyle = ['-', '-.']
133
+
134
+ p_up = ax1.plot(arr, bands[0].T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
135
+ p_do = ax1.plot(arr, bands[1].T, color=color[1], linewidth=0.8, linestyle=linestyle[1])
136
+ ax1.legend([p_up[0], p_do[0]], ['up', 'down'], frameon=False, prop={'style':'italic', 'size':'small'}, alignment='left', loc=location, title=legend[0], title_fontproperties={'size':'small'})
137
+ num = len(index_f)
138
+ if num + 2 > len(color):
139
+ color = color + [''] * (num + 2 - len(color))
140
+
141
+ if num + 2 > len(linestyle):
142
+ linestyle = linestyle + ['-'] * (num + 2 - len(linestyle))
143
+
144
+ for i in range(num):
145
+ if color[i+2]:
146
+ ax2.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+2], color=color[i+2])
147
+ else:
148
+ ax2.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+2])
149
+
150
+ ax1.tick_params(axis='y', which='minor', color='gray')
151
+ ax2.minorticks_on()
152
+ ax2.tick_params(axis='both', which='minor', color='gray')
153
+ ax2.axvline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
154
+ ax2.set_yticklabels([])
155
+ ax2.legend(elements, frameon=False, prop={'size':'small'}, alignment='left', loc=location, title="Density of states", title_fontproperties={'size':'small'})
156
+ ax1.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
157
+ ax2.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
158
+ if len(ticks) > 2:
159
+ ticks[0],ticks[-1] = arr[0],arr[-1]
160
+ for i in ticks[1:-1]:
161
+ ax1.axvline(i,linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
162
+
163
+ ax1.set_xlim(arr[0], arr[-1])
164
+ ax1.set_ylim(vertical)
165
+ ax2.set_xlim(horizontal)
166
+ ax2.set_ylim(vertical)
167
+ ax1.set_xticks(ticks,labels)
168
+ ax2.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
169
+ ax1.set_ylabel('Energy (eV)')
170
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
171
+
172
+ def DispinWd(EXPORT, figsize, vertical, horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, location, color):
173
+ fig, (ax1, ax2, ax3) = plt.subplots(1, 3, width_ratios=[0.5*(1-width_ratios), 0.5*(1-width_ratios), width_ratios], figsize=figsize)
174
+ fig.subplots_adjust(wspace=0.0)
175
+ if len(color) < 2:
176
+ color = ['r', 'k']
177
+
178
+ if len(linestyle) < 2:
179
+ linestyle = ['-', '-.']
180
+
181
+ ax1.plot(arr, bands[0].T, color=color[0], linewidth=0.8, linestyle=linestyle[0])
182
+ ax2.plot(arr, bands[1].T, color=color[1], linewidth=0.8, linestyle=linestyle[1])
183
+ ax1.legend(['up'], frameon=False, prop={'style':'italic', 'size':'small'}, alignment='left', loc=location, title=legend[0], title_fontproperties={'size':'small'})
184
+ ax2.legend(['down'], frameon=False, prop={'style':'italic', 'size':'small'}, alignment='left', loc=location)
185
+ ax1.tick_params(axis='y', which='minor', color='gray')
186
+ ax2.tick_params(axis='y', which='minor', color='gray')
187
+ ax3.minorticks_on()
188
+ ax3.tick_params(axis='both', which='minor', color='gray')
189
+ num = len(index_f)
190
+ if num + 2 > len(color):
191
+ color = color + [''] * (num + 2 - len(color))
192
+
193
+ if num + 2 > len(linestyle):
194
+ linestyle = linestyle + ['-'] * (num + 2 - len(linestyle))
195
+
196
+ for i in range(num):
197
+ if color[i+2]:
198
+ ax3.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+2], color=color[i+2])
199
+ else:
200
+ ax3.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i+2])
201
+
202
+ ax3.axvline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
203
+ ax2.set_yticklabels([])
204
+ ax3.set_yticklabels([])
205
+ ax3.legend(elements, frameon=False, prop={'size':'small'}, alignment='left', loc=location, title="Density of states", title_fontproperties={'size':'small'})
206
+
207
+ ax1.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
208
+ ax2.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
209
+ ax3.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
210
+ if len(ticks) > 2:
211
+ ticks[0],ticks[-1] = arr[0],arr[-1]
212
+ for i in ticks[1:-1]:
213
+ ax1.axvline(i,linewidth=0.5,linestyle=(0, (3, 2, 1, 2, 1, 2)),c='gray')
214
+ ax2.axvline(i,linewidth=0.5,linestyle=(0, (3, 2, 1, 2, 1, 2)),c='gray')
215
+
216
+ ax1.set_xlim(arr[0], arr[-1])
217
+ ax1.set_ylim(vertical)
218
+ ax2.set_xlim(arr[0], arr[-1])
219
+ ax2.set_ylim(vertical)
220
+ ax3.set_xlim(horizontal)
221
+ ax3.set_ylim(vertical)
222
+ ax1.set_xticks(ticks,labels[:-1]+[''])
223
+ ax2.set_xticks(ticks,labels)
224
+ ax3.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
225
+ ax1.set_ylabel('Energy (eV)')
226
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
227
+
228
+ def pdosfiles(EXPORT, figsize, vertical, horizontal, darr, dele, index_f, elements, linestyle, legend, location, exchange, color):
229
+ plt.figure(figsize=figsize)
230
+ plt.minorticks_on()
231
+ plt.tick_params(axis='both', which='minor', color='gray')
232
+ num = len(index_f)
233
+ if num > len(color):
234
+ color = color + [''] * (num - len(color))
235
+
236
+ if num > len(linestyle):
237
+ linestyle = linestyle + ['-'] * (num - len(linestyle))
238
+
239
+ if exchange:
240
+ for i in range(num):
241
+ if color[i]:
242
+ plt.plot(darr[index_f[i][0]], dele[index_f[i][0]].T[index_f[i][1]], linewidth=0.8, linestyle=linestyle[i], color=color[i])
243
+ else:
244
+ plt.plot(darr[index_f[i][0]], dele[index_f[i][0]].T[index_f[i][1]], linewidth=0.8, linestyle=linestyle[i])
245
+
246
+ plt.tick_params(axis='y', labelsize='medium', labelcolor='dimgray')
247
+ plt.xlim(vertical)
248
+ plt.ylim(horizontal)
249
+ plt.xlabel('Energy (eV)')
250
+ plt.ylabel('Density of states, electrons/eV')
251
+ else:
252
+ for i in range(num):
253
+ if color[i]:
254
+ plt.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i], color=color[i])
255
+ else:
256
+ plt.plot(dele[index_f[i][0]].T[index_f[i][1]], darr[index_f[i][0]], linewidth=0.8, linestyle=linestyle[i])
257
+
258
+ plt.tick_params(axis='x', labelsize='medium', labelcolor='dimgray')
259
+ plt.ylim(vertical)
260
+ plt.xlim(horizontal)
261
+ plt.ylabel('Energy (eV)')
262
+ plt.xlabel('Density of states, electrons/eV')
263
+
264
+ plt.axvline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
265
+ plt.axhline(linewidth=0.5, linestyle=(0, (3, 2, 1, 2, 1, 2)), c='gray')
266
+ plt.legend(elements, frameon=False, prop={'size':'medium'}, loc=location, title=legend[0], title_fontproperties={'size':'medium'})
267
+ plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
@@ -1,4 +1,5 @@
1
1
  import numpy as np
2
+ import re, glob
2
3
 
3
4
  def klabels(KLABELS):
4
5
  with open(KLABELS, "r") as main_file:
@@ -17,10 +18,17 @@ def klabels(KLABELS):
17
18
 
18
19
  return ticks, labels
19
20
 
21
+ def s_dosfile(DOS):
22
+ dosfiles = []
23
+ for i in DOS:
24
+ dosfiles = dosfiles + glob.glob(i)
25
+
26
+ return dosfiles
27
+
20
28
  def dos(DOS):
21
29
  ARR = []
22
30
  ELE = []
23
- elements = []
31
+ s_elements = []
24
32
  for pdos in DOS:
25
33
  with open(pdos, "r") as main_file:
26
34
  lines = main_file.readlines()
@@ -36,9 +44,68 @@ def dos(DOS):
36
44
 
37
45
  ARR.append(np.array(arr))
38
46
  ELE.append(np.array(ele).reshape(len(arr),-1))
39
- elements = elements + [pdos+'-'+i for i in lines[0].split()[1:]]
47
+ s_elements.append([re.sub('.dat|^[A-Za-z]+_', '', pdos)] + lines[0].split()[1:])
48
+
49
+ return ARR, ELE, s_elements
50
+
51
+ def select(s_elements, partial):
52
+ partial = [i for i in partial if i.split()]
53
+ num = len(s_elements)
54
+ if partial:
55
+ if partial[0] == 'all':
56
+ index = []
57
+ for i in range(num):
58
+ for j in range(len(s_elements[i])):
59
+ if j > 0:
60
+ index.append((i,j))
61
+ else:
62
+ index = []
63
+ for str0 in partial:
64
+ if str0.islower():
65
+ str = str0.split(',')
66
+ for index_i in range(num):
67
+ for i, j in enumerate(s_elements[index_i]):
68
+ for s in str:
69
+ if j == s and i > 0:
70
+ index.append((index_i, i))
71
+ else:
72
+ str = [i for i in str0.split('-') if i.split()]
73
+ if len(str) == 1:
74
+ index_i = -1
75
+ for i, j in enumerate([k[0] for k in s_elements]):
76
+ if j == str[0]:
77
+ index_i = i
78
+ if index_i >= 0:
79
+ for i in range(len(s_elements[index_i])):
80
+ if i > 0:
81
+ index.append((index_i,i))
82
+ elif len(str) == 2:
83
+ index_i = -1
84
+ for i, j in enumerate([k[0] for k in s_elements]):
85
+ if j == str[0]:
86
+ index_i = i
87
+ if index_i >= 0:
88
+ for i, j in enumerate(s_elements[index_i]):
89
+ for s in str[1].split(','):
90
+ if j == s and i > 0:
91
+ index.append((index_i, i))
92
+ else:
93
+ index = []
94
+ for i in range(num):
95
+ index.append((i, -1))
96
+
97
+ labels_elements = []
98
+ for i in index:
99
+ labels_elements.append(s_elements[i[0]][0] + '-$' + s_elements[i[0]][i[1]] + '$')
40
100
 
41
- return ARR, ELE, elements
101
+ index_f = []
102
+ for s in index:
103
+ if s[1] > 0:
104
+ index_f.append((s[0],s[1]-1))
105
+ else:
106
+ index_f.append(s)
107
+
108
+ return index_f, labels_elements
42
109
 
43
110
  def bands(PLOT):
44
111
  with open(PLOT, "r") as main_file:
@@ -46,7 +113,7 @@ def bands(PLOT):
46
113
 
47
114
  str0 = lines[0].split()
48
115
  if len(str0) == 2 and str0[1] == "Energy-Level(eV)":
49
- nkps = lines[1].split()
116
+ nkps = re.sub(':', ' ', lines[1]).split()
50
117
  m, n = int(nkps[-2]), int(nkps[-1])
51
118
  arr = np.zeros(m)
52
119
  bands = np.zeros((n,m))
@@ -112,3 +179,13 @@ def bands(PLOT):
112
179
  else:
113
180
  pass
114
181
 
182
+ def symbols(POSCAR):
183
+ with open(POSCAR, "r") as main_file:
184
+ lines = main_file.readlines()
185
+
186
+ symbol = lines[5].split()
187
+ factor = [int(i) for i in lines[6].split()]
188
+
189
+ return symbol, factor
190
+
191
+
@@ -0,0 +1,144 @@
1
+ import argparse, os, re
2
+ import matplotlib.pyplot as plt
3
+ from bandplot import plots, readdata
4
+
5
+ def main():
6
+ parser = argparse.ArgumentParser(description='Plot the band structure from vaspkit result.',
7
+ epilog='''
8
+ Example:
9
+ bandplot -i band.dat -o pband.png -l g m k g -d PDOS*
10
+ ''',
11
+ formatter_class=argparse.RawDescriptionHelpFormatter)
12
+ parser.add_argument('-v', "--version", action="version", version="bandplot "+get_version(os.path.join(os.path.dirname(__file__), "__init__.py")))
13
+ parser.add_argument('-s', "--size", type=int, nargs=2)
14
+ parser.add_argument('-b', "--divided", action='store_true', help="plot the up and down spin in divided subplot")
15
+ parser.add_argument('-y', "--vertical", type=float, nargs=2, help="energy (eV) range")
16
+ parser.add_argument('-g', "--legend", type=str, nargs=1, help="legend labels")
17
+ parser.add_argument('-a', "--location", type=str.lower, default='best',
18
+ choices=['best', 'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center'],
19
+ help="arrange the legend location, default best")
20
+ parser.add_argument('-k', "--linestyle", type=str, nargs='+', default=['-'], help="linestyle: solid; dashed; dashdot; dotted or tuple")
21
+ parser.add_argument('-c', "--color", type=str, nargs='+', default=[],
22
+ help="plot colors: b, blue; g, green; r, red; c, cyan; m, magenta; y, yellow; k, black; w, white")
23
+ parser.add_argument('-i', "--input", default="BAND.dat", type=str, help="plot figure from .dat file, default BAND.dat")
24
+ parser.add_argument('-o', "--output", default="BAND.png", type=str, help="plot figure filename, default BAND.png")
25
+ parser.add_argument('-K', "--klabels", default="KLABELS", type=str)
26
+ parser.add_argument('-l', "--labels", type=str.upper, nargs='+', default=[], help='labels for high-symmetry points, such as X S Y K M')
27
+ parser.add_argument('-d', "--dos", type=str, nargs='+', default=[], help="plot DOS from .dat file")
28
+ parser.add_argument('-x', "--horizontal", type=float, nargs=2, help="Density of states, electrons/eV range")
29
+ parser.add_argument('-n', "--exchange", action='store_true', help="exchange the x and y axes of DOS")
30
+ parser.add_argument('-p', "--partial", type=str, nargs='+', default=[], help='the partial DOS to plot, s p d')
31
+ parser.add_argument('-e', "--elements", type=str, nargs='+', default=[], help="PDOS labels")
32
+ parser.add_argument('-w', "--wratios", type=float, help='width ratio for DOS subplot')
33
+ parser.add_argument('-f', "--font", type=str, default='STIXGeneral', help="font to use")
34
+
35
+ args = parser.parse_args()
36
+
37
+ labels = [re.sub("'|‘|’", '′', re.sub('"|“|”', '″', re.sub('^GA[A-Z]+$|^G$', 'Γ', i))) for i in args.labels]
38
+ elements = [re.sub("'|‘|’", '′', re.sub('"|“|”', '″', i)) for i in args.elements]
39
+ dosfiles = readdata.s_dosfile(args.dos)
40
+ linestyle = []
41
+ for i in args.linestyle:
42
+ if len(i) > 2 and i[0] == '(' and i[-1] == ')':
43
+ linestyle.append(eval(i))
44
+ elif len(i.split('*')) == 2:
45
+ j = i.split('*')
46
+ linestyle = linestyle + [j[0]] * int(j[1])
47
+ else:
48
+ linestyle.append(i)
49
+
50
+ pltname = os.path.split(os.getcwd())[-1]
51
+ formula = ''
52
+ if os.path.exists('POSCAR'):
53
+ symbol, factor = readdata.symbols('POSCAR')
54
+ for i in range(len(symbol)):
55
+ if factor[i] > 1:
56
+ formula = formula + symbol[i] + '$_'+ str(factor[i]) + '$'
57
+ else:
58
+ formula = formula + symbol[i]
59
+
60
+ legend = args.legend
61
+ if not legend:
62
+ if formula:
63
+ legend = [formula]
64
+ else:
65
+ legend = [pltname]
66
+
67
+ color = []
68
+ for i in args.color:
69
+ j = i.split('*')
70
+ if len(j) == 2:
71
+ color = color + [j[0]] * int(j[1])
72
+ else:
73
+ color.append(i)
74
+
75
+ plt.rcParams['xtick.direction'] = 'in'
76
+ plt.rcParams['ytick.direction'] = 'in'
77
+ plt.rcParams['ytick.minor.visible'] = True
78
+ plt.rcParams['font.family'] = '%s'%args.font
79
+ plt.rcParams["mathtext.fontset"] = 'cm'
80
+
81
+ if os.path.exists(args.input):
82
+ if not args.vertical:
83
+ vertical = [-5.0, 5.0]
84
+ else:
85
+ vertical = args.vertical
86
+
87
+ arr, bands, ispin = readdata.bands(args.input)
88
+ ticks = []
89
+ klabels = []
90
+ if os.path.exists(args.klabels):
91
+ ticks, klabels = readdata.klabels(args.klabels)
92
+
93
+ if len(labels) == 0:
94
+ labels=[re.sub('GAMMA|Gamma|G', 'Γ', re.sub('Undefined|Un|[0-9]', '', i)) for i in klabels]
95
+
96
+ if len(ticks) > len(labels):
97
+ labels=labels + [''] * (len(ticks) - len(labels))
98
+
99
+ if not dosfiles:
100
+ if ispin == "Noneispin":
101
+ plots.Noneispin(args.output, args.size, vertical, arr, bands, ticks, labels, linestyle, legend, args.location, color)
102
+ elif ispin == "Ispin" and not args.divided:
103
+ plots.Ispin(args.output, args.size, vertical, arr, bands, ticks, labels, linestyle, legend, args.location, color)
104
+ elif ispin == "Ispin" and args.divided:
105
+ plots.Dispin(args.output, args.size, vertical, arr, bands, ticks, labels, linestyle, legend, args.location, color)
106
+ else:
107
+ darr, dele, s_elements = readdata.dos(args.dos)
108
+ index_f, labels_elements = readdata.select(s_elements, args.partial)
109
+ if not elements:
110
+ elements = labels_elements
111
+ if not args.wratios:
112
+ if not args.divided:
113
+ width_ratios = 0.5
114
+ else:
115
+ width_ratios = 0.3
116
+ else:
117
+ width_ratios = args.wratios
118
+
119
+ if ispin == "Noneispin":
120
+ plots.NoneispinWd(args.output, args.size, vertical, args.horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, args.location, color)
121
+ elif ispin == "Ispin" and not args.divided:
122
+ plots.IspinWd(args.output, args.size, vertical, args.horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, args.location, color)
123
+ elif ispin == "Ispin" and args.divided:
124
+ plots.DispinWd(args.output, args.size, vertical, args.horizontal, arr, bands, ticks, labels, darr, dele, index_f, elements, width_ratios, linestyle, legend, args.location, color)
125
+
126
+ else:
127
+ if dosfiles:
128
+ darr, dele, s_elements = readdata.dos(dosfiles)
129
+ index_f, labels_elements = readdata.select(s_elements, args.partial)
130
+ if not elements:
131
+ elements = labels_elements
132
+
133
+ plots.pdosfiles(args.output, args.size, args.vertical, args.horizontal, darr, dele, index_f, elements, linestyle, legend, args.location, args.exchange, color)
134
+ else:
135
+ print('No .dat file!')
136
+
137
+ def get_version(rel_path: str) -> str:
138
+ with open(rel_path) as fp:
139
+ lines = fp.readlines()
140
+ for line in lines:
141
+ if line.startswith("__version__"):
142
+ delim = '"' if '"' in line else "'"
143
+ return line.split(delim)[1]
144
+ raise RuntimeError("Unable to find version string.")
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.1
2
+ Name: bandplot
3
+ Version: 0.1.1
4
+ Summary: bandplot: band structure plot from vaspkit result.
5
+ Home-page: https://github.com/lkccrr/bandplot
6
+ Author: kan
7
+ Author-email: luokan@hrbeu.edu.cn
8
+ License: MIT
9
+ Description: .. image:: https://img.shields.io/pypi/v/pbandplot.svg
10
+ :target: https://pypi.org/project/pbandplot/
11
+
12
+ .. image:: https://img.shields.io/pypi/pyversions/pbandplot.svg
13
+ :target: https://pypi.org/project/pbandplot/
14
+
15
+ pbandplot
16
+ =========
17
+
18
+ pbandplot: Plot the phonon band structure plot from phonopy result.
19
+
20
+ * To execute ``pbandplot -h`` for the parameters to use.
21
+ * Example::
22
+
23
+ pbandplot -i band.dat -o pband.png -l g m k g -d projected_dos.dat
24
+ pbandplot -b 23 100 -l g m k g -y -2 110
25
+
26
+
27
+ Keywords: VASP band structure plot
28
+ Platform: Unix
29
+ Platform: Windows
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Programming Language :: Python
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3 :: Only
34
+ Classifier: Programming Language :: Python :: 3.6
35
+ Classifier: Programming Language :: Python :: 3.7
36
+ Classifier: Programming Language :: Python :: 3.8
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Requires-Python: >=3.6
41
+ Description-Content-Type: text/x-rst
@@ -1,4 +1,5 @@
1
1
  LICENSE.txt
2
+ README.rst
2
3
  setup.py
3
4
  bandplot/__init__.py
4
5
  bandplot/plots.py
@@ -1,24 +1,39 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
+ def get_version(rel_path: str) -> str:
4
+ with open(rel_path) as fp:
5
+ lines = fp.readlines()
6
+ for line in lines:
7
+ if line.startswith("__version__"):
8
+ delim = '"' if '"' in line else "'"
9
+ return line.split(delim)[1]
10
+ raise RuntimeError("Unable to find version string.")
11
+
3
12
  setup(
4
13
  name='bandplot',
5
- version='0.1.0',
14
+ version=get_version("bandplot/__init__.py"),
6
15
  author='kan',
7
16
  author_email='luokan@hrbeu.edu.cn',
8
17
  python_requires=">=3.6",
9
18
  license='MIT',
10
19
  license_files=('LICENSE.txt',),
11
20
  platforms=['Unix', 'Windows'],
12
- keywords='band structure plot',
21
+ keywords='VASP band structure plot',
13
22
  description='bandplot: band structure plot from vaspkit result.',
23
+ long_description=open('README.rst').read(),
24
+ long_description_content_type='text/x-rst',
14
25
  url='https://github.com/lkccrr/bandplot',
15
26
  classifiers=[
16
27
  'License :: OSI Approved :: MIT License',
28
+ "Programming Language :: Python",
17
29
  'Programming Language :: Python :: 3',
30
+ "Programming Language :: Python :: 3 :: Only",
18
31
  'Programming Language :: Python :: 3.6',
19
32
  'Programming Language :: Python :: 3.7',
20
33
  'Programming Language :: Python :: 3.8',
21
- 'Programming Language :: Python :: 3.9'
34
+ 'Programming Language :: Python :: 3.9',
35
+ "Programming Language :: Python :: 3.10",
36
+ "Programming Language :: Python :: 3.11"
22
37
  ],
23
38
  install_requires=[
24
39
  'numpy>=1.22.0',
bandplot-0.1.0/PKG-INFO DELETED
@@ -1,19 +0,0 @@
1
- Metadata-Version: 1.2
2
- Name: bandplot
3
- Version: 0.1.0
4
- Summary: bandplot: band structure plot from vaspkit result.
5
- Home-page: https://github.com/lkccrr/bandplot
6
- Author: kan
7
- Author-email: luokan@hrbeu.edu.cn
8
- License: MIT
9
- Description: UNKNOWN
10
- Keywords: band structure plot
11
- Platform: Unix
12
- Platform: Windows
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: 3.7
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Requires-Python: >=3.6
@@ -1,184 +0,0 @@
1
- import matplotlib.pyplot as plt
2
-
3
- def Noneispin(arr, bands, ticks, EXPORT, labels, figsize, vertical, legend, color):
4
- plt.figure(figsize=figsize)
5
- plt.plot(arr,bands.T,color='%s'%color,linewidth=0.8,linestyle='-')
6
- plt.tick_params(axis='y', which='minor', color='gray')
7
-
8
- plt.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
9
- if len(ticks) > 2:
10
- ticks[0],ticks[-1] = arr[0],arr[-1]
11
- for i in ticks[1:-1]:
12
- plt.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
13
-
14
- plt.xticks(ticks,labels)
15
- plt.legend(legend, frameon=False, prop={'size':'medium'}, loc='best')
16
- plt.xlim(arr[0], arr[-1])
17
- plt.ylim(vertical)
18
- plt.ylabel('Energy (eV)')
19
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
20
-
21
- def Ispin(arr, bands, ticks, EXPORT, labels, figsize, vertical, legend, color):
22
- plt.figure(figsize=figsize)
23
- p_up = plt.plot(arr,bands[0].T,color='%s'%color,linewidth=0.8,linestyle='-')
24
- p_do = plt.plot(arr,bands[1].T,color='k', linewidth=0.9,linestyle=':')
25
- plt.legend([p_up[0], p_do[0]], ['up', 'down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best', title=legend[0], title_fontproperties={'size':'medium'})
26
- plt.tick_params(axis='y', which='minor', color='gray')
27
-
28
- plt.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
29
- if len(ticks) > 2:
30
- ticks[0],ticks[-1] = arr[0],arr[-1]
31
- for i in ticks[1:-1]:
32
- plt.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
33
-
34
- plt.xlim(arr[0], arr[-1])
35
- plt.ylim(vertical)
36
- plt.xticks(ticks,labels)
37
- plt.ylabel('Energy (eV)')
38
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
39
-
40
- def Dispin(arr, bands, ticks, EXPORT, labels, figsize, vertical, legend, color):
41
- fig, (ax1, ax2) = plt.subplots(1, 2, figsize=figsize)
42
- fig.subplots_adjust(wspace=0.0)
43
- ax1.plot(arr,bands[0].T,color='%s'%color,linewidth=0.8,linestyle='-')
44
- ax2.plot(arr,bands[1].T,color='k', linewidth=0.9,linestyle=':')
45
- ax1.legend(['up'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best', title=legend[0], title_fontproperties={'size':'medium'})
46
- ax2.legend(['down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best')
47
- ax1.tick_params(axis='y', which='minor', color='gray')
48
- ax2.tick_params(axis='y', which='minor', color='gray')
49
-
50
- ax1.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
51
- ax2.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
52
- ax2.set_yticklabels([])
53
- if len(ticks) > 2:
54
- ticks[0],ticks[-1] = arr[0],arr[-1]
55
- for i in ticks[1:-1]:
56
- ax1.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
57
- ax2.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
58
-
59
- ax1.set_xlim(arr[0], arr[-1])
60
- ax1.set_ylim(vertical)
61
- ax2.set_xlim(arr[0], arr[-1])
62
- ax2.set_ylim(vertical)
63
- ax1.set_xticks(ticks,labels)
64
- ax2.set_xticks(ticks,labels)
65
- ax1.set_ylabel('Energy (eV)')
66
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
67
-
68
- def NoneispinWd(arr, bands, ticks, EXPORT, labels, figsize, vertical, darr, dele, elements, horizontal, width_ratios, legend, color):
69
- fig, (ax1, ax2) = plt.subplots(1, 2, width_ratios=[1-width_ratios, width_ratios], figsize=figsize)
70
- fig.subplots_adjust(wspace=0.0)
71
- ax1.plot(arr,bands.T,color='%s'%color,linewidth=0.8,linestyle='-')
72
- ax1.legend(legend, frameon=False, prop={'size':'medium'}, alignment='left', loc='best')
73
- ax1.tick_params(axis='y', which='minor', color='gray')
74
- ax2.tick_params(axis='y', which='minor', color='gray')
75
- for i in range(len(darr)):
76
- ax2.plot(dele[i],darr[i],linewidth=0.8)
77
-
78
- ax2.axvline(linewidth=0.4,linestyle='-.',c='dimgray')
79
- ax2.set_yticklabels([])
80
- ax2.legend(elements, frameon=False, prop={'size':'x-small'}, loc='best', title="Density of states", title_fontproperties={'size':'x-small'})
81
-
82
- ax1.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
83
- ax2.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
84
- if len(ticks) > 2:
85
- ticks[0],ticks[-1] = arr[0],arr[-1]
86
- for i in ticks[1:-1]:
87
- ax1.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
88
-
89
- ax1.set_xlim(arr[0], arr[-1])
90
- ax1.set_ylim(vertical)
91
- ax2.set_xlim(horizontal)
92
- ax2.set_ylim(vertical)
93
- ax1.set_xticks(ticks,labels)
94
- ax2.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
95
- ax1.set_ylabel('Energy (eV)')
96
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
97
-
98
- def IspinWd(arr, bands, ticks, EXPORT, labels, figsize, vertical, darr, dele, elements, horizontal, width_ratios, legend, color):
99
- fig, (ax1, ax2) = plt.subplots(1, 2, width_ratios=[1-width_ratios, width_ratios], figsize=figsize)
100
- fig.subplots_adjust(wspace=0.0)
101
- p_up = ax1.plot(arr,bands[0].T,color='%s'%color,linewidth=0.8,linestyle='-')
102
- p_do = ax1.plot(arr,bands[1].T,color='k', linewidth=0.9,linestyle=':')
103
- ax1.legend([p_up[0], p_do[0]], ['up', 'down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best', title=legend[0], title_fontproperties={'size':'medium'})
104
- ax1.tick_params(axis='y', which='minor', color='gray')
105
- ax2.tick_params(axis='y', which='minor', color='gray')
106
- for i in range(len(darr)):
107
- ax2.plot(dele[i],darr[i],linewidth=0.8)
108
-
109
- ax2.axvline(linewidth=0.4,linestyle='-.',c='dimgray')
110
- ax2.set_yticklabels([])
111
- ax2.legend(elements, frameon=False, prop={'size':'x-small'}, loc='best', title="Density of states", title_fontproperties={'size':'x-small'})
112
-
113
- ax1.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
114
- ax2.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
115
- if len(ticks) > 2:
116
- ticks[0],ticks[-1] = arr[0],arr[-1]
117
- for i in ticks[1:-1]:
118
- ax1.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
119
-
120
- ax1.set_xlim(arr[0], arr[-1])
121
- ax1.set_ylim(vertical)
122
- ax2.set_xlim(horizontal)
123
- ax2.set_ylim(vertical)
124
- ax1.set_xticks(ticks,labels)
125
- ax2.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
126
- ax1.set_ylabel('Energy (eV)')
127
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
128
-
129
- def DispinWd(arr, bands, ticks, EXPORT, labels, figsize, vertical, darr, dele, elements, horizontal, width_ratios, legend, color):
130
- fig, (ax1, ax2, ax3) = plt.subplots(1, 3, width_ratios=[0.5*(1-width_ratios), 0.5*(1-width_ratios), width_ratios], figsize=figsize)
131
- fig.subplots_adjust(wspace=0.0)
132
- ax1.plot(arr,bands[0].T,color='%s'%color,linewidth=0.8,linestyle='-')
133
- ax2.plot(arr,bands[1].T,color='k', linewidth=0.9,linestyle=':')
134
- ax1.legend(['up'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best', title=legend[0], title_fontproperties={'size':'medium'})
135
- ax2.legend(['down'], frameon=False, prop={'style':'italic', 'size':'medium'}, alignment='left', loc='best')
136
- ax1.tick_params(axis='y', which='minor', color='gray')
137
- ax2.tick_params(axis='y', which='minor', color='gray')
138
- ax3.tick_params(axis='y', which='minor', color='gray')
139
- for i in range(len(darr)):
140
- ax3.plot(dele[i],darr[i],linewidth=0.8)
141
-
142
- ax3.axvline(linewidth=0.4,linestyle='-.',c='dimgray')
143
- ax2.set_yticklabels([])
144
- ax3.set_yticklabels([])
145
- ax3.legend(elements, frameon=False, prop={'size':'x-small'}, loc='best', title="Density of states", title_fontproperties={'size':'x-small'})
146
-
147
- ax1.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
148
- ax2.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
149
- ax3.axhline(linewidth=0.8,linestyle='-.',c='dimgray')
150
- if len(ticks) > 2:
151
- ticks[0],ticks[-1] = arr[0],arr[-1]
152
- for i in ticks[1:-1]:
153
- ax1.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
154
- ax2.axvline(i,linewidth=0.4,linestyle='-.',c='gray')
155
-
156
- ax1.set_xlim(arr[0], arr[-1])
157
- ax1.set_ylim(vertical)
158
- ax2.set_xlim(arr[0], arr[-1])
159
- ax2.set_ylim(vertical)
160
- ax3.set_xlim(horizontal)
161
- ax3.set_ylim(vertical)
162
- ax1.set_xticks(ticks,labels)
163
- ax2.set_xticks(ticks,labels)
164
- ax3.tick_params(axis='x', labelsize='x-small', labelcolor='dimgray', labelrotation=-90, pad=1.5)
165
- ax1.set_ylabel('Energy (eV)')
166
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
167
-
168
- def dosfiles(EXPORT, figsize, darr, dele, vertical, horizontal, legend, elements):
169
- plt.figure(figsize=figsize)
170
- plt.tick_params(axis='y', labelsize='small', labelcolor='dimgray')
171
- plt.tick_params(axis='y', which='minor', color='gray')
172
- plt.minorticks_on()
173
- plt.tick_params(axis='x', which='minor', color='gray')
174
- for i in range(len(darr)):
175
- plt.plot(darr[i], dele[i], linewidth=0.8)
176
-
177
- plt.axvline(linewidth=0.8,linestyle='-.',c='dimgray')
178
- plt.axhline(linewidth=0.4,linestyle='-.',c='dimgray')
179
- plt.legend(elements, frameon=False, prop={'size':'medium'}, loc='best')
180
- plt.xlim(vertical)
181
- plt.ylim(horizontal)
182
- plt.xlabel('Energy (eV)')
183
- plt.ylabel('Density of states, electrons/eV')
184
- plt.savefig(EXPORT, dpi=750, transparent=True, bbox_inches='tight')
@@ -1,99 +0,0 @@
1
- import argparse, os, re, glob
2
- import matplotlib.pyplot as plt
3
- from bandplot import plots, readdata
4
-
5
- def main():
6
- pltname = [os.path.split(os.getcwd())[-1]]
7
- parser = argparse.ArgumentParser(description='Plot the band structure from vaspkit result.',
8
- epilog='''
9
- Example:
10
- bandplot -i band.dat -o pband.png -l g m k g -d PDOS*
11
- ''',
12
- formatter_class=argparse.RawDescriptionHelpFormatter)
13
- parser.add_argument('-v', "--version", action="version", version="bandplot 0.1.0")
14
- parser.add_argument('-s', "--size", type=int, nargs=2)
15
- parser.add_argument('-y', "--vertical", default=[-5.0, 5.0], type=float, nargs=2, help="energy range (eV)")
16
- parser.add_argument('-g', "--legend", type=str, nargs=1, default=pltname, help="legend labels")
17
- parser.add_argument('-c', "--color", type=str, default='red', help="plot color")
18
- parser.add_argument('-i', "--input", default="BAND.dat", type=str, help="plot figure from .dat file")
19
- parser.add_argument('-o', "--output", default="BAND.png", type=str, help="plot figure filename")
20
- parser.add_argument('-k', "--klabels", default="KLABELS", type=str)
21
- parser.add_argument('-l', "--labels", type=str.upper, nargs='+', default=[], help='labels for high-symmetry points')
22
- parser.add_argument('-d', "--dos", type=str, nargs='+', default=[], help="plot DOS from .dat file")
23
- parser.add_argument('-x', "--horizontal", type=float, nargs=2, help="Density of states, electrons/eV")
24
- parser.add_argument('-e', "--elements", type=str, nargs='+', default=[], help="PDOS labels")
25
- parser.add_argument('-w', "--wratios", type=float, help='width ratio for DOS subplot')
26
- parser.add_argument('-f', "--font", type=str, default='STIXGeneral', help="font to use")
27
- parser.add_argument('-b', "--divided", action='store_true', help="plot the up and down spin in divided subplot")
28
-
29
- args = parser.parse_args()
30
-
31
- labels = [re.sub("'|‘|’", '′', re.sub('"|“|”', '″', re.sub('^GA[A-Z]+$|^G$', 'Γ', i))) for i in args.labels]
32
- elements = [re.sub("'|‘|’", '′', re.sub('"|“|”', '″', i)) for i in args.elements]
33
- legend = args.legend
34
- color = args.color
35
-
36
- plt.rcParams['xtick.direction'] = 'in'
37
- plt.rcParams['ytick.direction'] = 'in'
38
- plt.rcParams['ytick.minor.visible'] = True
39
- plt.rcParams['font.family'] = '%s'%args.font
40
- plt.rcParams["mathtext.fontset"] = 'cm'
41
-
42
- if os.path.exists(args.input):
43
- arr, bands, ispin = readdata.bands(args.input)
44
- ticks = []
45
- klabels = []
46
- if os.path.exists(args.klabels):
47
- ticks, klabels = readdata.klabels(args.klabels)
48
-
49
- if len(labels) == 0:
50
- labels=[re.sub('GAMMA|Gamma|G', 'Γ', re.sub('Undefined|Un|[0-9]', '', i)) for i in klabels]
51
-
52
- diff = len(ticks)-len(labels)
53
- if diff > 0:
54
- for i in range(diff):
55
- labels=labels+['']
56
-
57
- if len(args.dos) == 0:
58
- if ispin == "Noneispin":
59
- plots.Noneispin(arr, bands, ticks, args.output, labels, args.size, args.vertical, legend, color)
60
- elif ispin == "Ispin" and not args.divided:
61
- plots.Ispin(arr, bands, ticks, args.output, labels, args.size, args.vertical, legend, color)
62
- elif ispin == "Ispin" and args.divided:
63
- plots.Dispin(arr, bands, ticks, args.output, labels, args.size, args.vertical, legend, color)
64
- else:
65
- dosfile = []
66
- for i in args.dos:
67
- dosfile = dosfile + glob.glob(i)
68
-
69
- darr, dele, s_elements = readdata.dos(dosfile)
70
- if not args.wratios:
71
- if not args.divided:
72
- width_ratios = 0.5
73
- else:
74
- width_ratios = 0.3
75
- else:
76
- width_ratios = args.wratios
77
-
78
- if len(elements) == 0:
79
- elements = [re.sub('.dat|^[A-Za-z]+_', '', i) for i in s_elements]
80
-
81
- if ispin == "Noneispin":
82
- plots.NoneispinWd(arr, bands, ticks, args.output, labels, args.size, args.vertical, darr, dele, elements, args.horizontal, width_ratios, legend, color)
83
- elif ispin == "Ispin" and not args.divided:
84
- plots.IspinWd(arr, bands, ticks, args.output, labels, args.size, args.vertical, darr, dele, elements, args.horizontal, width_ratios, legend, color)
85
- elif ispin == "Ispin" and args.divided:
86
- plots.DispinWd(arr, bands, ticks, args.output, labels, args.size, args.vertical, darr, dele, elements, args.horizontal, width_ratios, legend, color)
87
-
88
- else:
89
- if args.dos:
90
- dosfile = []
91
- for i in args.dos:
92
- dosfile = dosfile + glob.glob(i)
93
-
94
- darr, dele, s_elements = readdata.dos(dosfile)
95
- if len(elements) == 0:
96
- elements = [re.sub('.dat|^[A-Za-z]+_', '', i) for i in s_elements]
97
-
98
- plots.dosfiles(args.output, args.size, darr, dele, args.vertical, args.horizontal, legend, elements)
99
-
@@ -1,19 +0,0 @@
1
- Metadata-Version: 1.2
2
- Name: bandplot
3
- Version: 0.1.0
4
- Summary: bandplot: band structure plot from vaspkit result.
5
- Home-page: https://github.com/lkccrr/bandplot
6
- Author: kan
7
- Author-email: luokan@hrbeu.edu.cn
8
- License: MIT
9
- Description: UNKNOWN
10
- Keywords: band structure plot
11
- Platform: Unix
12
- Platform: Windows
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: 3.7
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Requires-Python: >=3.6
File without changes
File without changes