I am trying to create a histogram from some data I have and just to get an idea of the frequencies and bins etc I set a table so that instead of plotting it it put the information about the histogram into a particular file. So for example if my data was
11
12
11
11
15
12
10
then I get something like
10 1
11 3
12 2
15 1
where the second column gives the frequencies of each entry. But what I've noticed is that when gnuplot creates this file, instead of getting what I get above I get
10 1
11 3
12 2
15 1
10 1
i.e. the first entry is repeated again at the end of the table. If I wanted to plot just the histogram i.e. this file, its fine, no problem. But what I need to do is to plot the frequencies in logscale and if I don't correct this, i.e. manually load the file each time and then get rid of the last line, this plots an odd point way off the rest of the trend of my data.. I was wondering why this happens and if theres any way to turn it off? The code I use is the following:
set table 'tableavalanchesizeGSA'
bw = 50.0
bin(x,s)=s*int(x/s)
plot 'avalanche_size_GSA.dat' using (bin($1,bw)+bw/2.0):(1.0/2048000) smooth frequency with points
unset table
set logscale y
plot 'tableavalanchesizeGSA' with points title ''
Does anyone know why this is happening? And if there's an automatic way of turning it off?
This behaviour is a gnuplot bug. To circumvent this bug, you can pipe your table output through
head
before writing to the output file:You must skip the last two lines, because gnuplot writes an empty line at the end. Also you must use
set output
explicitely, piping seems not to work when setting the output withset table "| head ..."
.