#-------------------------------------------------------------------------- # gnuplot commands to fit data in a file named test_exp.dat to a # a 3-parameter exponential function. Modify the initial parameter # estimates as needed. # # to run this script, at the gnuplot prompt type: # gnuplot> load '563_exp_fit.gnu' #-------------------------------------------------------------------------- # -- helps to clear and unset some things if run the script more than # -- once in a gnuplot session clear unset y2label unset y2tics unset x2zeroaxis # -- uncomment two set.. lines below for postscript file output (will not # -- plot on the screen) #set terminal postscript enhanced "Helvetica" 16 # enhanced=super/sub/symbol #set output "junk.ps" set nokey # don't print file names on plot set origin 0.1, 0.1 # ranges are 0-1 set size 0.8,0.7 # relative axis sizes set xlabel "Time, s" # special symbols will only work set ylabel "Absorbance" # for postscript enhanced set xrange [0:5.0] # important -- will eliminate points if wrong in fitting set yrange [0:0.6] # make room for residuals at the bottom set xtics 0,1 # major tics start,interval, set mxtics 2 # minor tics, number of subintervals between major tics set ytics nomirror 0,0.2 # major tics start,interval, set mytics 2 # minor tics, number of subintervals between major tics f(x)=a*exp(-b*x)+c # fitting equation a=-0.6 # initial estimate b=2.0 # initial estimate c= 0.6 # initial estimate fit f(x) 'test_exp.dat' using 1:2 via a,b,c # -- uncomment line below to plot data and calculated values without residuals # plot f(x), 'test_exp.dat' using 1:2 with lines # -- uncomment section below to plot only the residuals # set yrange [-0.006:0.006] # set ytics nomirror -0.01,0.002 # major tics start,interval, # set mytics 2 # minor tics, number of subintervals between major tics # plot 'test_exp.dat' using 1:(f($1)-$2) with lines # -- uncomment section below to plot data and calculated values with residuals set y2range [-0.001:0.01] set y2tics border set y2label "Residual" set x2zeroaxis lt -1 plot f(x),'test_exp.dat' using 1:2 with lines,\ 'test_exp.dat' using 1:(f($1)-$2) axes x1y2 with lines