Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth line on histograms in gnuplot

I want to make a smooth line over histograms. So far I have tried all the smooth functions but I am not able to get the result.

For the histograms I am using:

plot "file.scatter" u (hist($2,width)):(1.0) smooth freq w boxes notitle

and the result is:this

But when I ask gnuplot to draw a smooth line over these:

plot "file.scatter" u (hist($2,width)):(1.0) smooth freq w l notitle

I get: this

I want the line plot to look smooth like a probability density function(of course the values will have to be normalized).

Any clues experts?

like image 853
Harris Avatar asked Jul 30 '26 13:07

Harris


1 Answers

You need to do a convolution, if you have a recent version of gnuplot (>=5.1) you can plot with kdensity

plot $DATA smooth kdensity [bandwidth n] with boxes

Keep in mind that recent versions of gnuplot can also do the binning for the histogram with the bins feature.

like image 60
Gavin Portwood Avatar answered Aug 01 '26 05:08

Gavin Portwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!