-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_band.py
More file actions
26 lines (20 loc) · 829 Bytes
/
plot_band.py
File metadata and controls
26 lines (20 loc) · 829 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
import matplotlib.pyplot as plt
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import BSPlotter
# Load VASP band structure from vasprun.xml
vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True)
band_structure = vasprun.get_band_structure(line_mode=True)
plt.figure(figsize=(18, 8))
# Plot using pymatgen's built-in Band Structure Plotter
plotter = BSPlotter(band_structure)
plotter.get_plot()
plt.gcf().canvas.draw() # populate tick labels
ax = plt.gca()
labels = [tick.get_text() for tick in ax.get_xticklabels()]
new_labels = []
for s in labels:
s2 = s.replace("Gamma", r"$\Gamma$").replace("GAMMA", r"$\Gamma$")
new_labels.append(s2)
ax.set_xticklabels(new_labels, fontsize=14)
plt.ylim(-1, 1.5)
plt.savefig("band.pdf",format='pdf', dpi=300, bbox_inches='tight')