Back to demo index

gnuplot demo script: bins.dem

autogenerated by webify.pl on Wed Aug 21 21:18:07 2024
gnuplot version gnuplot 6.1 last modified 2024-08-21
#
# Demo illustrating the relationship between
# a binned histogram and a kernel density model of the same data.
#
$DATA << EOD
1	1
2	1
8	1
9	1
17	1
17	1
9	1
9	1
5	1
7	1
7	1
8	1
8	1
8	1
10	1
11	1
11	1
12	1
14	1
3	1
3	1
3	1
8	7
15	1
17	1
17	1
18	1
19	1
20	1
EOD

set title "Comparison of a binned histogram and\na kernel density model of the same data"

set style data lines
set xtics 1 norangelimit nomirror
set grid y
set yrange [0:5.5]
set style fill solid 0.5 noborder
set jitter spread 0.5

plot $DATA using 1 bins=20 with boxes title '20 bins', \
        '' using 1:(1) smooth kdensity bandwidth .5 lw 2 title 'smooth kdensity', \
        '' using 1:(.9) with impulse lc "black" title 'jittered data'
 

Click here for minimal script to generate this plot