Page 1 of 1

How to plot electron spectral function

Posted: Sun Mar 05, 2017 1:26 am
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

Re: How to plot electron spectral function

Posted: Sun Mar 05, 2017 11:00 am
by sponce
Dear Fawei Zheng,

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

Best,

Samuel

Re: How to plot electron spectral function

Posted: Sun Mar 05, 2017 11:42 am
by Fawei
Dear Samuel,
Thanks for your reply.
Did you use ' surf(X,Y,Z); shading interp; view(2) ' commands in matlab?
Best,
Fawei

Re: How to plot electron spectral function

Posted: Wed Mar 22, 2017 6:05 am
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()       
###############