My script:
set term postscript enhanced colour
set output 'dos.ps
set key box font 'Helvetica, 12' left center
set key at 6,15
set grid
set size noratio 1, 0.8
set style fill transparent solid 1.0 noborder
set style data filledcurves y1=0
set arrow from 0, graph 0 to 0, graph 1 nohead
set xlabel "E-E_f [eV]" font 'Helvetica, 20'
set arrow 5 head filled size screen 0.02,13 from -0.5,-17.3 to 0.4,-17.3 lc rgb "black" lw 3
set arrow 6 head filled size screen 0.02,13 from -9.05,5.5 to -9.05,8.4 lc rgb "black" lw 3
set ylabel "Density of states" font 'Helvetica, 20'
plot [-5:3] [-10:10] 'dos.dat' using ($1-12.6258):2 with filledcu lc rgb "red" title "Spin Up",'dos.dat' using ($1-12.6258):($3*-1) with filledcu lc rgb "#4169E1" title "Spin Down",0.0 lc rgb "black" title '','dos.dat' with lines lc rgb "black" title ''
set output
! ps2pdf -r300 dos.ps
! rm dos.ps
! pdftocairo -png -r 300 dos.pdf
What I get:
What I want:
Why are the curves not filled with the above script?
There are a few things in your script which I don't understand:
why are you creating a postscript file which you later convert to PDF and then to PNG. Why not directly using terminal pngcairo
?
set key at 6,15
is outside the graph
set size noratio 1, 0.8
What's the purpose of this?
set style data filledcurves y1=0
(haven't seen/used this so far)
arrows 5 and 6 are outside the graph
... 0.0 lc rgb "black" title ''
Plot the x-axis again?
...'dos.dat' with lines lc rgb "black" ...
Plot a black outline again?
Check the following minimized script as starting point. You posted only data as image which doesn't help too much. So, I used some data.
Data: SO74355087.dat
7.0 1.0 1.0
7.5 0.1 1.0
8.0 3.0 4.0
8.5 4.0 3.0
9.0 0.5 2.0
9.5 7.0 5.0
10.0 4.0 7.0
10.5 1.0 1.0
11.0 0.0 2.0
11.5 9.0 3.0
12.0 0.0 0.0
12.5 3.0 0.0
13.0 2.5 0.0
13.5 2.0 0.0
14.0 1.0 5.0
14.5 1.0 3.0
15.0 0.5 1.0
15.5 0.0 0.5
Script:
### plot with filledcurves
reset session
FILE = "SO74355087.dat"
set key box font 'Helvetica, 12' top right noautotitle
set grid
set style fill transparent solid 1.0 noborder
set xlabel "E-E_f [eV]" font 'Helvetica, 20'
set ylabel "Density of states" font 'Helvetica, 20'
set xzeroaxis
set xrange[-5:3]
set yrange[-10:10]
set term pngcairo size 640,384
set output "SO74355087.png"
plot FILE u ($1-12.6258):2 w filledcurves y=0 lc rgb "red" ti "Spin Up", \
'' u ($1-12.6258):(-$3) w filledcurves y=0 lc rgb "#4169E1" ti "Spin Down"
set output
### end of script
Result:
Addition:
Ok, you want to smooth the curve. Check help smooth
. There are different options: e.g. bezier
, splines
, kdensity
. Depending on what data you have and what you want to see (how smooth) you need to play with these options.
For the script above, if you use the same data but change the plotting lines to:
plot $Data u ($1-12.6258):2 smooth cspline w filledcurves y=0 lc rgb "red" ti "Spin Up", \
'' u ($1-12.6258):(-$3) smooth kdensity bandwidth 0.2 w filledcurves y=0 lc rgb "#4169E1" ti "Spin Down"
You will get the following. Please read help smooth
for getting a deeper understanding.
Addition: smoothing options
Please read help smooth
and play with the numbers set sample 500
and if you use smooth kdensity bandwidth 0.02
.
Script:
### plot with filledcurves
reset session
FILE = "SO74355087.dat"
FILE = "dos.dat"
set key box font 'Helvetica, 12' top right noautotitle
set grid
set style fill transparent solid 1.0 noborder
set style data filledcurves y1=0
set xlabel "E-E_f [eV]" font 'Helvetica, 20'
set ylabel "Density of states" font 'Helvetica, 20'
set xzeroaxis
set xrange[-5:3]
set yrange[*:*]
set term pngcairo size 640,900
set output "SO74355087.png"
set samples 500
set multiplot layout 3,1
plot FILE u ($1-12.6258):2 w filledcurves y=0 lc rgb "red" ti "Spin Up", \
'' u ($1-12.6258):(-$3) w filledcurves y=0 lc rgb "#4169E1" ti "Spin Down"
plot FILE u ($1-12.6258):2 smooth bezier w filledcurves y=0 lc rgb "red" ti "Spin Up", \
'' u ($1-12.6258):(-$3) smooth bezier w filledcurves y=0 lc rgb "#4169E1" ti "Spin Down"
plot FILE u ($1-12.6258):2 smooth kdensity bandwidth 0.02 w filledcurves y=0 lc rgb "red" ti "Spin Up", \
'' u ($1-12.6258):(-$3) smooth kdensity bandwidth 0.02 w filledcurves y=0 lc rgb "#4169E1" ti "Spin Down"
unset multiplot
set output
### end of script
Result:
Top graph: original data as is
Middle graph: smooth bezier
Bottom graph: smooth kdensity bandwidth 0.02
You might want to scale the y-values... or remove ytics to have arbitraty units...