Hello Everyone,
I have successfully obtained the 2D complex band structure for my system but the obtained plot does not have the scale division on either of the two axes. The script I used for this purpose is as below -
from NanoLanguage import *
import matplotlib.pyplot as plt
import math
# Read the complex bandstructure object from the NC file
cbs = nlread('/home/swapanchem/mehboob/cdcomplex-complexbandk5-121-k55-10001points-e-0-5.nc', object_id="gID003")[0]
energies = cbs.energies().inUnitsOf(eV)
k_real, k_complex = cbs.evaluate()
ax = plt.axes()
cmap="Spectral"
# First plot the real bands
kvr = numpy.array([])
e = numpy.array([])
for (j, energy) in enumerate(energies):
k = k_real[j]*cbs.layerSeparation()/math.pi
if len(k)>0:
e = numpy.append(e,[energy,]*len(k))
kvr = numpy.append(kvr,k)
# Plot
ax.scatter(kvr, e,
c=numpy.abs(kvr),
cmap=cmap, marker='o', linewidths=0, s=10)
# Next plot the complex bands
kvr = numpy.array([])
kvi = numpy.array([])
e = numpy.array([])
for (j, energy) in enumerate(energies):
if len(k_complex[j])>0:
kr = [numpy.abs(x.real) for x in k_complex[j]]
ki = [numpy.abs(x.imag) for x in k_complex[j]]
e = numpy.append(e,[energy,]*len(kr))
kvr = numpy.append(kvr,kr)
kvi = numpy.append(kvi,ki)
# Plot with color depending on the imaginary part (corresponding to real k-points)
sc = ax.scatter(-kvi,e,
c=kvr,
cmap=cmap, marker='o', linewidths=0, s=10)
# Put on labels and decorations
ax.axvline(0,color='b')
ax.grid(True, which='major')
ax.set_xlim(-1, 1)
ax.set_ylim(-5, 1)
plt.xticks([])
plt.yticks([])
ax.annotate('$\kappa$ (1/Ang)', xy=(0.25,-0.07), xycoords="axes fraction", ha="center")
ax.annotate('$kL / \pi$', xy=(0.75,-0.07), xycoords="axes fraction", ha="center")
ax.set_ylabel('Energy / eV')
# Add a colorbar
fig = plt.gcf()
x1, x2, y1, y2 = 0., 1, ax.get_ylim()[0], ax.get_ylim()[0]+1
trans = ax.transData + fig.transFigure.inverted()
ax_x1, ax_y1 = trans.transform_point([x1, y1])
ax_x2, ax_y2 = trans.transform_point([x2, y2])
ax_dx, ax_dy = ax_x2 - ax_x1, ax_y2 - ax_y1
cmap_axes = plt.axes([ax_x1, ax_y1, ax_dx, ax_dy])
a = numpy.outer(numpy.arange(0,1,0.01),numpy.ones(10)).transpose()
cmap_plt = plt.imshow(a,aspect='auto',cmap=plt.get_cmap(cmap),origin=(0,0))
plt.show()
I have tried to change the two lines
ax.set_xlim
ax.set_ylim
but without any success.
Kindly tell me which parameter in the script should I change to get the axis scale properly.
With best regards,
Mehboob