! Example of binning. ! Author: Francois Tonneau size 14 10 set font ss ! The raw data in binning.dat are 1160 response durations by a Wistar rat ! pressing a lever. begin graph data "binning.dat" x2axis off y2axis off side off ticks off labels dist 0.25 xtitle "Response duration (s)" hei 0.4 dist 0.5 ytitle "Frequency" hei 0.4 dist 0.4 ! We use the 'hist' command with the 'bins' option to bin the d1 data into ! dataset d2, and we plot the results as a frequency polygon. ! *Note*: instead of specifying a number of bins with 'bins', we could have ! specified the size of each bin with the 'step' option. This alternative is ! less precise, however, and its use is not recommended. let d2 = hist d1 from 0 to 2.50 bins 50 d2 line marker fcircle msize 0.18 end graph include dsave.gle ! We save dataset d2 to the 'binning_results.txt' file, using 3 decimal places ! for the x values and 0 decimal places for the y values (dsave also accepts a ! string argument as header, see the dsave.gle library file for details). dsave d2 binning_results.txt 3 0 include graphutil.gle ! We add plot decorations; 'dmeany' computes the mean of a dataset. mean = dmeany(d1) set lstyle 22 hei 0.35 just cc graph_vline mean amove xg(mean) yg(145) write "Mean" ! We end by plotting the first 200 raw values in an inset graph. amove 7.5 4.5 begin graph size 4 3 fullsize subticks off xaxis min 0 max 200 dticks 50 yaxis min 0 max 2 dticks 0.5 xtitle "First 200 responses" dist 0.3 ytitle "Duration (s)" dist 0.3 data "binning.dat" let d2 = d1 from 1 to 200 d2 line lwidth 0.01 end graph