set term pdf fontscale 0.75 size 5in,3in outfile = 'ClosedOrbitDistortion.pdf' set output outfile #set term x11 b1=-26.9 a1=22.8;a2=0.1;a3=0.1;a4=0.1 p1=2.1;p2=0.1;p3=0.1;p4=0.1 f(x) = b1 + a1*cos(x +p1) + a2*cos(2*x +p2) + a3*cos(3*x +p3) + a4*cos(4*x +p4) file = '~/development/bmad_dist/g-2/magneticfield/multipoles_run_07215.dat' set xrange [0:2*pi] set xlabel '{/Symbol q} [rad]' set ylabel '{/Symbol D}B [ppm]' set key left Left plot file u ($1*pi/180):2 w l pause -1 fit f(x) file u ($1*pi/180):2 via b1, a1, p1 fit f(x) file u ($1*pi/180):2 via a2,p2 fit f(x) file u ($1*pi/180):2 via a3,p3 fit f(x) file u ($1*pi/180):2 via a4,p4 fit f(x) file u ($1*pi/180):2 via b1, a1, p1,a2,p2,a3,p3,a4,p4 plot file u ($1*pi/180):2 w l t 'measurement' ,f(x) t 'fit' print outfile