Fill the area between two functions / 두 함수 사이 채우기

1st trial – failed ㅜㅡㅜ 실패

blog1

$dataset << EOF
65.35 5.85359394298859E-11 0.1349370225 484.3
58.4 5.95078799482906E-11 0.1232847794 473.7
64.1 6.04796391953728E-11 0.1095913831 584.9
96.15 6.14512142109854E-11 0.0998131423 963.3
111.2 6.24226020355423E-11 0.094317218 1179
68.55 6.33937997100278E-11 0.0904592241 757.8
42.9 6.43648042760053E-11 0.0949745406 451.7
33.3 6.53356127756266E-11 0.0826918301 402.7
38.35 6.63062222516405E-11 0.1003138896 382.3
94.2 6.72766297474024E-11 0.3208446866 293.6
316.5 6.82468323068826E-11 0.5102369821 620.3
1021 6.92168269746759E-11 0.6244648318 1635
1504 7.01866107960104E-11 0.6702317291 2244
886.4 7.11561808167563E-11 0.6541697417 1355
303.3 7.21255340834352E-11 0.6033419535 502.7
168.7 7.30946676432289E-11 0.5617715618 300.3
159.6 7.40635785439886E-11 0.582694414 273.9
149.6 7.50322638342435E-11 0.5510128913 271.5
144.4 7.60007205632104E-11 0.5410266017 266.9
137.6 7.69689457808021E-11 0.5434439179 253.2
126.4 7.79369365376366E-11 0.5253532835 240.6
EOF

unset label
set terminal wxt font ',13'
set ytics nomirror
set xtics nomirror
set xlabel "Wavelength[10^{-11}m]"
set ylabel "R: I_{f}/I_{0}"

#Linear
f1(x)= a1*x+b1
fit f1(x) $dataset every ::0::3 u ($2*1.0E+11):3 via a1, b1

f2(x)= a2*x+b2
fit f2(x) $dataset every ::16::20 u ($2*1.0E+11):3 via a2, b2

a3 = 1
f3(x)= a3*x+b3
fit f3(x) $dataset every ::8::11 u ($2*1.0E+11):3 via a3, b3

g1(x) =x<=6.7530 && x>=6.585 ? f1(x) : sqrt(-1)
g3(x) =x<=6.7530 && x>=6.585 ? f3(x) : sqrt(-1)
g2(x) =x<=6.912738 && x>= 6.7530 ? f2(x) : sqrt(-1)
g32(x) =x<=6.912738 && x>=6.7530 ? f3(x) : sqrt(-1)
unset arrow
set arrow nohead from 6.753000, 0 to 6.753000, 0.8 lw 2

set yrange [0:0.8]
set xrange [5.80: 7.80]
unset xtics
set xtics 6.00,.50,7.50
set xtics add ("{/Symbol l}_{k}: 6.753" 6.753)
set label " E_{/Symbol a} 19832eV \n E_{/Symbol b} 17750eV \n E_{k} 18362eV" at 6.80580, 0.237137

set key above

plot \
'+' u 1:(g1($1)):(g3($1)) w filledcurves notitle fs pattern 5, \
'+' u 1:(g2($1)):(g32($1)) w filledcurves notitle fs pattern 5, \
f1(x) title sprintf("{%+.3f}{x} {%+.3f}", a1, b1),\
f2(x) title sprintf("{%+.3f}{x} {%+.3f}", a2, b2),\
f3(x) title ""

2nd trial – Success 예이! 이렇게 해야 하는 구만

blog2

$dataset << EOF
65.35 5.85359394298859E-11 0.1349370225 484.3
58.4 5.95078799482906E-11 0.1232847794 473.7
64.1 6.04796391953728E-11 0.1095913831 584.9
96.15 6.14512142109854E-11 0.0998131423 963.3
111.2 6.24226020355423E-11 0.094317218 1179
68.55 6.33937997100278E-11 0.0904592241 757.8
42.9 6.43648042760053E-11 0.0949745406 451.7
33.3 6.53356127756266E-11 0.0826918301 402.7
38.35 6.63062222516405E-11 0.1003138896 382.3
94.2 6.72766297474024E-11 0.3208446866 293.6
316.5 6.82468323068826E-11 0.5102369821 620.3
1021 6.92168269746759E-11 0.6244648318 1635
1504 7.01866107960104E-11 0.6702317291 2244
886.4 7.11561808167563E-11 0.6541697417 1355
303.3 7.21255340834352E-11 0.6033419535 502.7
168.7 7.30946676432289E-11 0.5617715618 300.3
159.6 7.40635785439886E-11 0.582694414 273.9
149.6 7.50322638342435E-11 0.5510128913 271.5
144.4 7.60007205632104E-11 0.5410266017 266.9
137.6 7.69689457808021E-11 0.5434439179 253.2
126.4 7.79369365376366E-11 0.5253532835 240.6
EOF
unset label
set terminal wxt font ',13'
set ytics nomirror
set xtics nomirror
set xlabel "Wavelength[10^{-11}m]"
set ylabel "R: I_{f}/I_{0}"
#Linear
f1(x)= a1*x+b1
fit f1(x) $dataset  every ::0::3  u ($2*1.0E+11):3 via a1, b1
f2(x)= a2*x+b2
fit f2(x) $dataset  every ::16::20  u ($2*1.0E+11):3 via a2, b2
a3 = 1
f3(x)= a3*x+b3
fit f3(x) $dataset  every ::8::11  u ($2*1.0E+11):3 via a3, b3
unset arrow
set arrow nohead  from  6.753000, 0 to  6.753000,  0.8 lw 2
set yrange [0:0.8]
set xrange [5.80: 7.80]
unset xtics
set xtics 6.00,.50,7.50
set xtics add ("{/Symbol l}_{k}: 6.753"  6.753)
set label " E_{/Symbol a} 19832eV \n E_{/Symbol b} 17750eV \n E_{k} 18362eV" at    6.80580,  0.237137


array = ""
do for [i=1:100]\
{\
w= 6.585+(6.7530-6.585)/100.0*i
array = array.sprintf( "%d \t %1.5f \t  %f \t %f \n", i, w,f1(w),f3(w))
\
}
set print "data1"
print array


array = ""
do for [i=1:100]\
{\
w= 6.7530+(6.912738-6.7530)/100.0*i
array = array.sprintf( "%d \t %1.5f \t  %f \t %f \n", i, w,f2(w),f3(w))
\
}
set print "data2"
print array


plot \
"data1" u 2:3:4 w filledcurve notitle fs pattern 5 ,\
"data2" u 2:3:4 w filledcurve notitle fs pattern 5 ,\
f1(x) notitle,\
f2(x) notitle,\
f3(x) notitle

Leave a Reply