Back to demo index

gnuplot demo script: smooth_splines.dem

autogenerated by webify.pl on Sun Sep 17 20:38:57 2023
gnuplot version gnuplot 6.0 patchlevel rc2
Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
# Plot smoothing with 
# natural cubic splines (smooth csplines)
# weighted approximate cubic splines (smooth acsplines)
# Bezier curve (smooth bezier)
# 2D and 3D acspline examples

print "various splines for smoothing"

set title "cubic spline fit to data (no weights)"
set samples 300
set xlabel "Time (sec)"
set ylabel "Rate"
plot "silver.dat" t "experimental" w errorb, \
               ""  smooth csplines t "cubic smooth" lw 2


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "acsplines weighted by relative error"
# error is column 3; weight larger errors less
# start with rel error = 1/($3/$2)
S=1
plot "silver.dat" t "experimental" w errorb,\
               "" u 1:2:(S*$2/$3) smooth acsplines t "acspline Y/Z" lw 2


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "acsplines with increasing weight from error estimate"
plot "silver.dat" t "rate" w errorb,\
               "" u 1:2:($2/($3*1.e1)) sm acs t "acspline Y/(Z*1.e1)" lw 2,\
               "" u 1:2:($2/($3*1.e3)) sm acs t "         Y/(Z*1.e3)" lw 2,\
               "" u 1:2:($2/($3*1.e5)) sm acs t "         Y/(Z*1.e5)" lw 2


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "Same plot (various weighting) in log scale"
set logscale y
set grid x y mx my
replot


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "Bezier curve rather than cubic spline"
unset logscale y
plot "silver.dat" t "experimental" w errorb,\
               "" smooth sbezier t "bezier" lw 2


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "Bezier curve with log scale"
set logscale y
replot

unset log
unset grid


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "3D smooth acsplines (special case with curve in single plane)"
set key right top
set key title "\n\n"
set xrange [0:600]
set yrange [0:600]
set zrange [0:300]
set xyplane at 0
unset xtics
set ytics offset 0,-1
set ylabel  "Time" offset 0,-2

set view 89.9 ,90, 1.5,1.0
splot "silver.dat" using (1):1:2 t "rate" w errorb,\
               "" u (1):1:2:($2/($3*1.e1)) smooth acs t "acspline Y/(Z*1.e1)" lw 2,\
               "" u (1):1:2:($2/($3*1.e3)) smooth acs t "         Y/(Z*1.e3)" lw 2,\
               "" u (1):1:2:($2/($3*1.e5)) smooth acs t "         Y/(Z*1.e5)" lw 2


Click here for minimal script to generate this plot


Your browser does not support the HTML 5 canvas element
          # unzoom rezoom zoom text ?
     
set title "3D acsplines (general case)\nNote much larger weight values needed"
set view 90,45,1.,1.5
unset xtics
unset ytics
unset xlabel
unset ylabel

W = 1.e7
set key title sprintf("\n\nW = %.2g", W)
splot "silver.dat" using 1:1:2 t "rate" w errorb,\
               "" u 1:1:2:(W * $2/($3*1.e1)) smooth acs lw 2,\
               "" u 1:1:2:(W * $2/($3*1.e3)) smooth acs lw 2,\
               "" u 1:1:2:(W * $2/($3*1.e5)) smooth acs lw 2


Click here for minimal script to generate this plot