I am trying to solve the eigenvalues of a 6x6 matrix as a function of a single parameter which I've called "e". As you can see from the code I evaluate the eigenvalues for a range of values in "detuning". I want to plot these 6 eigenvalues as a function of this detuning parameter. However due to the fact that the algorithm linalg.eigh() returns the the eigenvalues in ascending order, the information as to what eigenvalue corresponds to what eigenvector gets lost. So for example the horizontal lines at energy of 100 and -100 should be the same color, because they should belong to the same eigenvector. But I simple saved the eigenvalues from linalg.eigh() in the order I got it. And this order is not related to the eigenvectors so they split into different colors. So my question is, how do I keep track as to what eigenvalue belongs to what eigenvector? I am sorry if this is not clear, I have been having difficulty understanding the problem myself.
from scipy import linalg as la
ez = 100
dez = 14
t = 10
U = 1000
e=0
hc=np.zeros([6,6])
hc[0,0]=-ez
hc[1,1]=-dez/2;hc[1,4:6]=t
hc[2,2]=dez/2;hc[3,4:6]=-t
hc[3,3]=ez
hc[4,1]=t;hc[4,2]=-t;hc[4,4] = U-e
hc[5,1]=t;hc[5,2]=-t;hc[5,5]=U+e
detuning=np.arange(-1500,1500,10)
Energy = np.zeros((6,len(detuning)))
for i, ep in enumerate(detuning):
e = ep
hc=np.zeros([6,6])
hc[0,0]=-ez
hc[1,1]=-dez/2;hc[1,4:6]=t
hc[2,2]=dez/2;hc[3,4:6]=-t
hc[3,3]=ez
hc[4,1]=t;hc[4,2]=-t;hc[4,4] = U-e
hc[5,1]=t;hc[5,2]=-t;hc[5,5]=U+e
w,v = la.eigh(hc)
Energy[:,i] = w
for i in np.arange(6):
plt.plot(detuning,Energy[i,:], label = i)
plt.legend()
plt.xlabel("$\epsilon (\mu$eV)",fontsize=15)
plt.ylabel("Energy ($\mu$eV)",fontsize=15)
plt.ylim([-200,200])
plt.show()