How to plot electron spectral function

Post here questions linked with issue while running the EPW code

Moderator: stiwari

Post Reply
Fawei
Posts: 8
Joined: Thu Feb 23, 2017 11:09 am
Affiliation:

How to plot electron spectral function

Post by Fawei »

Dear developers/users,
I want to plot the electron spectral function, like figure 6-8 in B-doped diamond example. I use the color mapped method in Origin software, while the quality of the output figures is not good.
Could anyone please tell me a better method to plot electron spectral function?
Thanks,
Fawei Zheng

sponce
Site Admin
Posts: 616
Joined: Wed Jan 13, 2016 7:25 pm
Affiliation: EPFL

Re: How to plot electron spectral function

Post by sponce »

Dear Fawei Zheng,

I think I used Matlab for this but you can also use gnuplot or python (with matplotlib).

Best,

Samuel
Prof. Samuel Poncé
Chercheur qualifié F.R.S.-FNRS / Professeur UCLouvain
Institute of Condensed Matter and Nanosciences
UCLouvain, Belgium
Web: https://www.samuelponce.com

Fawei
Posts: 8
Joined: Thu Feb 23, 2017 11:09 am
Affiliation:

Re: How to plot electron spectral function

Post by Fawei »

Dear Samuel,
Thanks for your reply.
Did you use ' surf(X,Y,Z); shading interp; view(2) ' commands in matlab?
Best,
Fawei

Fawei
Posts: 8
Joined: Thu Feb 23, 2017 11:09 am
Affiliation:

Re: How to plot electron spectral function

Post by Fawei »

Dear all,
I have drafted a simple python code to plot electron spectral function, and would like to share the code here.
Hopefully, this may make it easier to plot the figure.
Best,
Fawei

Code: Select all

###############
import re
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors

## parameters
f=open('specfun.elself','r')   
fig_size_x=25      # figure size
fig_size_y=25      # figure size
step=100            # color steps
## end parameters

p=re.compile(r'-?\d+\.\d+E?-?\d+')
pint=re.compile(r'-?\d+')

file=f.readlines()
f.close()

y=[]
z=[[]]
zz=z[-1]
t1=1
for line in file:
    f=p.findall(line)
    t=pint.findall(line)
    if f!=[] and '#' not in line :
        t0=t1
        t1=int(t[0])
        if t1==1:   
            y.append(float(f[0]))
        if t0!=t1:
            z.append([])
            zz=z[-1]
        zz.append(float(f[1]))
x=range(t1)
Y,X = np.meshgrid(y,x)

fig, ax = plt.subplots(figsize=(fig_size_x,fig_size_y))
z=np.mat(z)
levs = np.arange(z.min(),z.max(), (z.max()-z.min())/step)
cs = ax.contourf(X, Y, z, levs, norm=colors.Normalize())
cbar = fig.colorbar(cs)

plt.show()       
###############

Post Reply