In [62]:
%pylab inline
a=1; L=1/a #Define initial parameters
x = linspace(0,L,100) 

def dist(x,y):    return (x**2+y**2)/L**2; #Energy of a point
def points(x,y): #Gets all the energys of one point in band theory
    y1=y ; E=[]
    for i in range(-2,3):
        for j in range(-2,3):
            E.append(dist(x+2*i*L,y+2*j*L))
    return E
#Plot the results
for i in range(25):
    plot(2*x,points(x,x)[i],'b')
    l = list(points(L,x)[i]);    l.reverse();    plot(2*x+2*L,l,'b')
    l2 = list(points(x,0)[i]);    l2.reverse();    plot(2*x+4*L,l2,'b')    
    ylim([0,18]);    xlim([0,6*L])
    axhline(y=16, color='g', linestyle='-',lw=2);    xposition = [2*L, 4*L]
    for xc in xposition:
        axvline(x=xc, color='r', linestyle='--',lw=2)
    #Axis.set_label_coords(x, y, transform=None)
    xticks( arange(7), ('$\Gamma$', '$\Sigma$', '$M$', '$Z$', '$X$','$\Delta$','$\Gamma$') )
    yticks( [0,4,8,16], ('$0$','$4$','$8$','$16$') )
    rcParams.update({'font.size': 22})
    rc("text", usetex = True)
    rc("font", family = "serif")
    ylabel("$E/\pi_1$")


Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['dist']
`%matplotlib` prevents importing * from pylab and numpy

In [79]:
from pylab import rcParams


plot()
#set_size_inches(18.5, 10.5)
nums = []
txt = []
suma = 0
for m in range(1,7): 
    a = -2*cos(m*pi/7)
    suma = suma+ 2*a
    print a
    axhline(y=a, color='b', linestyle='-',lw=2); 
    nums.append(a)
    txt.append('%.2f' % a )
    print suma  , m   
    
    
ylim([-2,2]);    xlim([0,1])
xticks( [], () )
yticks(nums, txt )
rcParams['figure.figsize'] = 1.5, 4
rc("text", usetex = True)
rc("font", family = "serif")
rcParams.update({'font.size': 20})
ylabel("$E/\epsilon_1$")
ylabel(r'$(E-\alpha)/(-\beta$)')


-1.8019377358
-3.60387547161 1
-1.24697960372
-6.09783467904 2
-0.445041867913
-6.98791841487 3
0.445041867913
-6.09783467904 4
1.24697960372
-3.60387547161 5
1.8019377358
-1.33226762955e-15 6
Out[79]:
<matplotlib.text.Text at 0x7fba929ec890>

In [34]:
str(5.9)


Out[34]:
'5.9'

In [37]:
'%.2f' % 5.1


Out[37]:
'5.10'

In [ ]: