Back to demo index

gnuplot demo script: smooth.dem

autogenerated by webify.pl on Wed Aug 21 21:29:00 2024
gnuplot version gnuplot 6.1 last modified 2024-08-21
#
# Find number of points
#
stats 'random-points' nooutput
N = STATS_records

bin(x, s) = s*int(x/s)

set zeroaxis
set style data points
set key box top left

# Uniform
set title "Uniform Distribution"
set boxwidth 0.05
set xrange [-0.1 : 1.1] noextend
set yrange [-0.4 : 1.6]
plot "random-points" u 1:(0.25*rand(0)-.35) t '', \
     "" u (bin($1,0.05)):(20./N) smooth freq t 'smooth frequency' w boxes, \
     "" u 1:(1.) smooth cnorm t 'smooth cnorm'

Click here for minimal script to generate this plot





# Normal
set title "Normal Distribution"
set boxwidth 0.05
set xrange [* : *] noextend
set yrange [-0.4 : 1.1]
set ytics 0,.2

plot "random-points" u 2:(0.25*rand(0)-.35) t '', \
     "" u (bin($2,0.05)):(20./N) smooth freq t 'smooth frequency' w boxes, \
     "" u 2:(1.) smooth cnorm t 'smooth cnorm'

Click here for minimal script to generate this plot





# Lognormal
set title "Lognormal Distribution"
set boxwidth 0.1
set xrange [0 : *] noextend
plot "random-points" u 3:(0.25*rand(0)-.35) t '', \
    "" u (bin($3,0.1)):(10./N) smooth freq t 'smooth frequency' w boxes, \
    "" u 3:(1.) smooth cnorm t 'smooth cnorm'

Click here for minimal script to generate this plot





# Mixed
set title "Mixed Distribution (Lognormal with shifted Gaussian)"
set boxwidth 0.1
set xrange [* : *] noextend
set link y2 via y*N inverse y/N
set ytics nomirror  0,.2
set y2tics nomirror tc "red" 0,50

plot "random-points" u 4:(0.25*rand(0)-.35) t '', \
     "" u (bin($4,0.1)):(10./N) smooth freq t 'smooth frequency' w boxes, \
     "" u 4:(1.) smooth cnorm t 'smooth cnorm' lc "#88eeff" lw 5, \
     "" u 4:(1.) axes x1y2 smooth cumulative t 'smooth cumulative' lc "red"

Click here for minimal script to generate this plot