How to export from gnuplot to extern datafile the frequency counts used to generate a histogram?

13,373

You can redirect the plot and save it in text format by setting table variable.

binc(bin_width,x) = bin_width * ( int(x/bin_width) + 0.5 )
set table "hist.dat"
plot 'datafile' u (binc(bin_width,$1)) : (1.0/size_sample ) smooth frequency
unset table

Your histogram will be saved in the file name "hist.dat".

Share:
13,373
Bruce_Warrior
Author by

Bruce_Warrior

Physicist, Linux and Mac User and a programmer but only with academic purposes

Updated on June 04, 2022

Comments

  • Bruce_Warrior
    Bruce_Warrior almost 2 years

    To plot a histogram I follow the book Gnuplot in Action and I use

    binc(bin_width,x) = bin_width * ( int(x/bin_width) + 0.5 )
    

    and to plot I use

    plot 'datafile' u (binc(bin_width,$1)) : (1.0/size_sample ) smooth frequency
    

    I have understood that smooth frecuency create a frecuency count for each bin and this is used by plot to make the histogram

    But, How can I create a variable that contain the frecuency, I want do this to export the values of each bin's frecuency counts to a file, for example.