#Libraries to manage different elements
#--------------------------------------
from matplotlib import pyplot as pl
import numpy as np
from matplotlib import rcParams
from matplotlib import gridspec
import matplotlib.ticker as ticker
#-------------------------------------

#Read the files two columns from a file
#---------------------------------------
total = np.loadtxt('total_dos.dat')
ti = np.loadtxt('ti_dos.dat')
ox = np.loadtxt('ox_dos.dat')
#---------------------------------------
#----Adjust the draw into the canvas
pl.subplots_adjust(left=0.10, bottom=0.10, right=0.98, top=0.98,
		 wspace=0.35, hspace=None)

#Plot Figure 1
#----------------------------------
fig = pl.figure(1)
ax1=pl.subplot2grid((1,2), (0,0))
ax1.fill(total[:,0], total[:,7], label='Total', alpha=0.4, color='gray')
ax1.fill(total[:,0], total[:,8], label='', alpha=0.4, color='gray')
ax1.plot(ti[:,0], ti[:,5], label='Ti (d)', lw=1.1, color='blue')
ax1.plot(ti[:,0], ti[:,6], label='', lw=1.1, color='blue')
ax1.plot(ox[:,0], ox[:,3], label='O  (p)', lw=1.1, color='red')
ax1.plot(ox[:,0], ox[:,4], label='', lw=1.1, color='red')

#items for figure 1
#-------------------------------------
pl.xlabel(r'Energy [eV]', x=0.5, y=0)    #X label
pl.ylabel("Density of States [states/eV]") #Y label 
pl.legend(loc=3, bbox_to_anchor=(0.20, 0.8), prop={'size':9})
pl.xlim(-8, 4)  # X range
pl.ylim(-15, 15)      # Y range

#Plot Figure 2
#----------------------------------
fig = pl.figure(1)
ax1=pl.subplot2grid((1,2), (0,1))
ax1.fill(total[:,0], total[:,7], label='Total', alpha=0.4, color='gray')
ax1.fill(total[:,0], total[:,8], label='', alpha=0.4, color='gray')
ax1.plot(ti[:,0], ti[:,5], label='Ti (d)', lw=1.1, color='blue')
ax1.plot(ti[:,0], ti[:,6], label='', lw=1.1, color='blue')
ax1.plot(ox[:,0], ox[:,3], label='O  (p)', lw=1.1, color='red')
ax1.plot(ox[:,0], ox[:,4], label='', lw=1.1, color='red')

#Items fot Figure 2
#-------------------------------------
pl.xlabel(r'Energy [eV]', x=0.5, y=0)    #X label
pl.ylabel("Density of States [states/eV]") #Y label 
pl.legend(loc=3, bbox_to_anchor=(0.20, 0.8), prop={'size':9})
pl.xlim(-8, 4)  # X range
pl.ylim(-15, 15)      # Y range

#Intructions for the exit format: png, eps, ps, svg
#---------------------------------------------------
pl.savefig('mult_plot.png',format='png', dpi=400)

pl.show()
