# Band Structure from EIGENVAL in VASP

So I am trying to plot the band structure from the EIGENVAL file produced by VASP. I wrote this Python code:

import numpy as np
import matplotlib.pyplot as mpl

mpl.rcParams["mathtext.fontset"] = "stix"   # Change the math font
mpl.rcParams["font.family"] = "STIXGeneral" # Change the global font

with open('EIGENVAL', 'r') as f:

nkpts = int(data[5].split()[1])
nbands = int(data[5].split()[2])

print(nkpts, nbands)

kpoints = []
energies = []
for i in range(nkpts):
line_index = 7+(nbands+2)*i
kpoint_coords = [float(x) for x in data[line_index].split()[:3]]
eigenvalues = []
for j in range(nbands):
eigenvalue = float(data[line_index+j+1].split()[1])
eigenvalues.append(eigenvalue)
kpoints.append(kpoint_coords)
energies.append(eigenvalues)

kpoints = np.array(kpoints)
energies = np.array(energies)

EF = 1.92675163
energies = (energies.T - EF).T

xaxis = [j for j in range(len(kpoints))]

mpl.xticks([xaxis[0], xaxis[int(len(xaxis)/2-1)], xaxis[-1]], ["L", "Γ", "X"])
for i in range(nbands):
mpl.plot(xaxis, energies[:, i])
mpl.axhline(y=0, linestyle='--')
# mpl.axhline(y=2, linestyle='--')
mpl.axvline(x=xaxis[0], linestyle='-')
mpl.axvline(x=xaxis[int(len(xaxis)/2-1)], linestyle='-')
mpl.axvline(x=xaxis[-1], linestyle='-')
mpl.xlabel('$$k$$-points')
mpl.ylabel('$$E-$$VBM [eV]')
mpl.savefig('BS.png', dpi=800, bbox_inches="tight")
mpl.show()


I am getting this figure:

I am defining the xaxis array which is rather arbitrary.

My question is: Is there a more efficient way to plot the band structure after extracting the data?

• Are you looking for ways to plot the band structure using the EIGENVAL file? Or is it okay if you get the plot using other VASP output files? If it is the latter case: see this and this question where you can find many post-processing tools. (The link to sumo is broken in the question. This is working) Apr 12, 2023 at 23:34
• Could you please clarify in your question what you mean by “better way to plot band structure”? what is your expected output of the plot? Apr 13, 2023 at 7:21
• Thanks so much @AbdulMuhaymin. This answers my question. Apr 13, 2023 at 20:29
• @Mohamed in that case, I will try to add it as an answer. Apr 13, 2023 at 21:51
• @AbdulMuhaymin very useful links, I had also tried in the past to extract by parsing the data of the vasp.xml file for a plot using gnuplot, but this is stuff already done and more efficiently. Apr 14, 2023 at 11:26