How to plot partial density of states in gnuplot? - gnuplot

I tried to plot using this script but it doesnt work well.
set term postscript enhanced colour
set output 'pdos.ps'
set key box font 'Helvetica, 12' top right noautotitle
set grid
set xlabel "E-E_f [eV]" font 'Helvetica, 20'
set ylabel "PDos(states/ev)" font 'Helvetica, 20'
set xzeroaxis
set xrange[-6:4]
set yrange[*:*]
plot 'Co_d.dat' u 1:2 w l lc "green", 'Mn_d.dat' u 1:2 w l lc "red', 'Sb_p.dat' u 1:2 w l lc "#4169E1"
set output
I expect this like this plot as in this image I mentioned.
I got image like this.

Plot your data first without setting a range, default is autorange or set xrange[*:*]. Then you will see the region of interest.
And in your case this is not set xrange[-6:4] as you set, but maybe set xrange[6:16].
Probably, you are looking for a script like this:
reset session
set key box font 'Helvetica, 12' top right noautotitle
set xlabel "E-E_f [eV]" font 'Helvetica, 20'
set xrange[-6:4]
set mxtics 2
set xzeroaxis lt 1 lc "black"
set ylabel "PDos(states/ev)" font 'Helvetica, 20'
set yrange[-10:10]
set yzeroaxis lt 1 dt 2 lw 1.5 lc "black"
set grid x,y
set label at first 0.25, first 5 "Spin-Up" font "Helvetica, 12"
set label at first 0.25, first -5 "Spin-Down" font "Helvetica, 12"
set label at first -0.5, first 8 "Fermi-Level" font "Helvetica, 12" right
set arrow from first 0.75, 5.5 to 0.75, 7.5
set arrow from first 0.75, -5.5 to 0.75, -7.5
set arrow from first -0.4, 8 to 0.0, 8
plot 'Co_d.dat' u ($1-12.6258):2 w l lc "green" ti "Co-4d", \
'' u ($1-12.6258):(-$3) w l lc "green", \
'Mn_d.dat' u ($1-12.6258):2 w l lc "red" ti "Mn-4d", \
'' u ($1-12.6258):(-$3) w l lc "red", \
'Sb_p.dat' u ($1-12.6258):2 w l lc "#4169E1" ti "Sb-2p", \
'' u ($1-12.6258):(-$3) w l lc "#4169E1"

Related

How to use gnuplot to plot history graph with labels

I have two small datafiles
one
11 365.4
12 659.2
and one
11 432.1
12 882.4
I try to plot those as a histogram with labels
gnuplot <<EOF
set output 'house-energy.png'
set terminal png size 800,400 font "Arial,10"
set boxwidth 0.7 relative
set grid ytics linestyle 0
set style fill solid 0.20 border
set style data histogram
#set style histogram columnstacked
#set style histogram rowstacked
set title "Energy"
set xlabel "Month"
set ylabel "kWh"
set yrange [0:2000]
plot 'file1.dat' u 2: xtic(1) with histogram lc rgb "#0045FF" title "Energy house total", \
'' using 1:(\$2):(\$2) with labels notitle font ",10" , \
'file2.dat' u 2: xtic(1) with histogram lc rgb "#004500" title "Labb", \
'' using 1:(\$2):(\$2) with labels notitle font ",10"
EOF
But the labels are way off
Image showing plot
// GH
The histogram plotting style is implicitly using the pseudocolumn 0 (check help pseudocolumns) as x-coordinate. So, you have to place your label at column(0) or ($0) with some x-offset, e.g. ($0-0.15) in the one and other direction. And some offset in y-direction, e.g. via offset 0,0.7.
Script:
### histogram with labels
reset session
$Data1 <<EOD
11 365.4
12 659.2
EOD
$Data2 <<EOD
11 432.1
12 882.4
EOD
set boxwidth 0.7 relative
set grid ytics linestyle 0
set style fill solid 0.20 border
set style data histogram
set title "Energy"
set xlabel "Month"
set ylabel "kWh"
set yrange [0:2000]
set key noautotitle
plot $Data1 u 2:xtic(1) w histogram lc rgb "#0045FF" title "Energy house total", \
'' u ($0-0.15):2:2 w labels font ",10" offset 0,0.7, \
$Data2 u 2 w histogram lc rgb "#004500" title "Labb", \
'' u ($0+0.15):2:2 w labels font ",10" offset 0,0.7
### end of script
Result:

what is wrong here for plotting dos in gnuplot?

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...

How to manage tick lable and axis-lable in gnu multiplot

I have two files each is having five columns where 1st will be the x-axis in both the data.
I want to make a multiplot 2 2 in GNU with zero spacing.
I could manage many things but I am could not fix below problems:
1. How to place the figure at the center of the page i.e. equal left right margin? I set the left, right, top and bottom margin but it is not working.
2. How to number the figure. For example, Figure 1 1 should be numbered as (a), figure 1 2 should be numbered as (b) and so on.
3. How to put tick lable and tick mark on the plot 1 2 and 2 2 on right side of the plot?
4. how to create a common title at the bottom of the figure representing the X-axis.
I have tried to make gnu multiplot layout but still it is not giving desired results. The script I used is mentioned below:
My code is
[![set terminal postscript eps enhanced size 20cm,15cm color solid lw 3 "Times-Roman" 24
reset
set lmargin screen 0.10
set rmargin screen 0.95
set bmargin screen 0.15
set tmargin screen 0.9
set mxtics 2
set mytics 2
set tics font "Times-bold, 50"
set output "absorption.pdf"
set multiplot layout 2,2 margin 0.2, 0.9, 0.1, 0.9 spacing 0.00, 0.00
set tics scale 1.2
set tics font "Times-bold, 26"
set key spacing 1.2
unset key
set xrange \[0:8.5\]
set yrange \[0:1\]
set xlabel ' '
set format x ""
set ylabel 'A11' font 'Times-bold, 26' offset 1,1,3
unset label
plot "data1.dat" u 1:($2/10**4) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($3/10**4) w l lw 3 lc rgb "blue" title "z-D"
unset label
unset format x
unset key
set key inside center top # to adjust the legends position
set xrange \[0:8.5\]
set yrange \[0:1\]
set title ' '
set xlabel ' '
set xlabel ' '
set format x ""
set ylabel ' '
set format y " "
set key spacing 1.2
set ylabel 'A12' font 'Times-bold, 26' offset 1,0,3
plot "data1.dat" u 1:($4/10**2) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($5/10**2) w l lw 3 lt 2 lc rgb "blue" title "Z-D"
unset label
unset format y
unset format x
unset key
set xrange \[0:8.5\]
set yrange \[0:1.08\]
set xlabel ' '
unset label
set ylabel 'A21' font 'Times-bold, 28'
unset label
plot "data2.dat" u 1:($2/10) w l lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($4/10) w l lw 3 lt 2 lc rgb "blue" title "z-dir" ,\
unset label
unset format x
unset key
set xrange \[0:8.5\]
set yrange \[0:1.08\]
set title ' '
set format y ""
set xlabel 'X-12-scale' font 'Times-bold, 28'
set ylabel 'A22' font 'Times-bold, 28'
plot "data2.dat" u 1:($3/10) w l lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($5/10) w l lw 3 lt 2 lc rgb "blue" title "z-dir"
unset label
unset format y
unset key
unset multiplot
set output][1]][1]
My data should be like what I want according to attached figure queries and hand marks.
Try this
reset
set encoding utf8
set terminal pngcairo size 750,500 font ",10"
set output "Multiplot_2x2.png"
set multiplot \
layout 2,2 rowsfirst \
title "{/:Bold=11 Multiplot 2×2}" \
margins screen 0.10,0.92,0.12,0.90 \
spacing screen 0.00,0.00
set link y2
# Gaussian fuction
f(x,a,b,c) = a*exp(-((x-b)/c)**2)
# Parameters to first one
a1 = 0.95
b1 = 4.00
c1 = 1.00
# Parameters to second one
a2 = 0.95
b2 = 5.00
c2 = 1.00
# Line style
set style line 1 lc "#e41a1c" # red
set style line 2 lc "#377eb8" # blue
# -----------------------------------------------
set xrange [0:10]
set yrange [0:1.0]
set xtics format ""
set ytics
set ylabel "y-label"
set label 1 "{/:Bold (a)}" at graph 0.05, 0.9
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
unset ylabel
set ytics format ""
set y2tics format ""
set y2label "y2-label"
set label 1 "{/:Bold (b)}"
plot f(x,a1,b1,c1) w l ls 1 title "Your title 1", f(x,a2,b2,c2) w l ls 2 title "Your title 2"
# -----------------------------------------------
unset y2tics
unset y2label
set xtics 0,2,9 format "%g"
set ytics 0,0.2,0.9 format "%g"
set ylabel "y-label"
set label 1 "{/:Bold (c)}"
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
unset ylabel
set xtics 0,2,10
set xlabel "common x-label" offset screen -0.20,0.0
set ytics format ""
set y2tics
set y2label "y2-label"
set label 1 "{/:Bold (d)}"
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
Result

Point color in gnuplot 4.0

When I try to plot three separate data files using gnuplot, I get an error "';' expected" in the output when I try to change the point color of the data sets.
For example, this works fine:
set terminal jpeg size 900,500
set xlabel 'x axis label'
set ylabel 'y axis label'
set title 'sample title'
set output "output.jpeg"
set xrange [-0.1:1.1]
set yrange [] reverse
set xtics 0.10
#set ytics 100
set key top left
set grid ytics lt 0 lw 1
set grid xtics lt 0 lw 1
plot 'file1.dat' u 1:2 w p pt 7 ps 0.8 ti 'dataset 1', \
'file2.dat' u 1:2 w p pt 6 ps 0.8 ti 'dataset 2', \
'file3.dat' u 1:2 w p pt 5 ps 0.8 ti 'dataset 3'
This does not:
set terminal jpeg size 900,500
set xlabel 'x axis label'
set ylabel 'y axis label'
set title 'sample title'
set output "output.jpeg"
set xrange [-0.1:1.1]
set yrange [] reverse
set xtics 0.10
#set ytics 100
set key top left
set grid ytics lt 0 lw 1
set grid xtics lt 0 lw 1
plot 'file1.dat' u 1:2 w p pt 7 ps 0.8 lc 9 ti 'dataset 1', \
'file2.dat' u 1:2 w p pt 6 ps 0.8 ti 'dataset 2', \
'file3.dat' u 1:2 w p pt 5 ps 0.8 ti 'dataset 3'
Why is this? Is there a workaround to simply change point color independent of point style and size?
Thanks!
The keyword linecolor (lc) was introduced in version 4.2. In your case you can change the color using linetype (lt):
set terminal jpeg size 900,500
set output "output.jpeg"
plot 'file1.dat' u 1:2 w p pt 7 ps 0.8 lt 9 ti 'dataset 1'
But I also strongly recommend you to upgrade!

Gnuplot not filling the lines in 3D graphics

I'm ploting with gnuplot but in the 3D graphics some areas are not completed, empty.
The question is simple: how to force it to fill the empty areas ?
Commands that I'm using:
fit (a**-(x**(y**b))) './Tabela_perda_01_MOS_70ms_com_sameq_GOP_30_2_Foot.txt' using 1:2:3:(1) via a,b
set clabel '%8.2f'
set key right
set xlabel "X"
set ylabel "Y"
set zlabel "Z"
set xrange [0:1]
set yrange [2:20]
set zrange [0:1]
set isosample 11,20
set pointsize 0.5
set style line 1 lt 1 lw 2 pt 3 lc rgb "black"
set style line 2 lt 1 lw 1 pt 3 lc rgb "black"
splot "./Tabela_perda_01_MOS_70ms_com_sameq_GOP_30_2_Foot.txt" using 1:2:3 notitle w points ls 1, (a**-(x**(y**b))) w l ls 2

Resources