Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 377
Bruce_Warrior Avatar asked Feb 23 '23 04:02

Bruce_Warrior


1 Answers

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".

like image 157
Sunhwan Jo Avatar answered Apr 06 '23 01:04

Sunhwan Jo