Very simple command to best fit using gnuplot

How calculate and plot a linear best fit using gnuplot with only a subset of data-file?
to generate an output like this:


you should use a command such:
f(x) = a * x + b
fit f(x) "datafile.data" every ::15:0:30:0
plot "datafile.data" ,  f(x)

It means that gnuplot perform the best fit calculation only for data from row 15 to row 30.

May be usefull select visually the subset of data to fitting in this way:
plot "datafile.data" every ::15:0:30:0 , ""


different color help you to select the desired subsection without modify the original data-file.

How make quick histogram using gnuplot [data elaboration]

Make an histogram using gnuplot isn't very simple if you have raw data (not collected in classes).
Here we show a quick and easy way to create and draw an histogram using gnuplot starting from raw data.

This is the command you have to use:

bw = 2   #substitute what you want
bin(x,width)=width*floor(x/width)
plot 'data.dat' using (bin($2,bw)):(1.0) smooth freq with boxes

And this is the output:



file "data.dat" exemple:
1 1
2 3
4 12
5 6
.....

[Via: http://www.nabble.com/gnuplot-histograms-td15811193.html]