|
From: David L. <lin...@ie...> - 2011-11-14 16:23:50
|
Hello, I would like to plot the distribution of a variable and I follow the directions given in the "Gnuplot in Action" book: I define a binning function: bin(x,s) = s*int(x/s) And then I use the plot command: plot './data.dat' u (bin($2, 0.2)):(1) smooth frequency However, the 'data.dat' file has a number of discontinuities in it (i.e. blank lines). This causes the output to show several sets of histograms, one for each continuous set of data. Is there any workaround for this? I would like the histogram to show the distribution in the whole file, and to ignore discontinuities. Thanks in advance, -- :::::::::::::::::::::::::::::::::::::::::::: David Lindelöf, Ph.D. +41 (0)79 415 66 41 or skype:david.lindelof Better Software for Tomorrow's Cities: http://computersandbuildings.com Follow me on Twitter: http://twitter.com/dlindelof |
|
From: Thomas S. <t.s...@fz...> - 2011-11-15 16:09:08
|
David Lindelöf <lindelof <at> ieee.org> writes: > I would like to plot the distribution of a variable and I follow the > directions given in the "Gnuplot in Action" book: > > I define a binning function: > > bin(x,s) = s*int(x/s) > > And then I use the plot command: > > plot './data.dat' u (bin($2, 0.2)):(1) smooth frequency > > However, the 'data.dat' file has a number of discontinuities in it > (i.e. blank lines). This causes the output to show several sets of > histograms, one for each continuous set of data. > > Is there any workaround for this? I would like the histogram to show > the distribution in the whole file, and to ignore discontinuities. maybe use an external program to omit the blank lines: plot '< awk "{if (NF) print}" ./data.dat' u (bin($2, 0.2)):(1) smooth frequency "awk" should be installed on every unix system, for windows systems google for 'awk windows'. |
|
From: walter h. <wh...@bf...> - 2011-11-15 16:13:54
|
Am 15.11.2011 17:08, schrieb Thomas Sefzick: > David Lindelöf <lindelof <at> ieee.org> writes: > >> I would like to plot the distribution of a variable and I follow the >> directions given in the "Gnuplot in Action" book: >> >> I define a binning function: >> >> bin(x,s) = s*int(x/s) >> >> And then I use the plot command: >> >> plot './data.dat' u (bin($2, 0.2)):(1) smooth frequency >> >> However, the 'data.dat' file has a number of discontinuities in it >> (i.e. blank lines). This causes the output to show several sets of >> histograms, one for each continuous set of data. >> >> Is there any workaround for this? I would like the histogram to show >> the distribution in the whole file, and to ignore discontinuities. > > maybe use an external program to omit the blank lines: > > plot '< awk "{if (NF) print}" ./data.dat' u (bin($2, 0.2)):(1) smooth frequency > > "awk" should be installed on every unix system, for windows systems google > for 'awk windows'. > > plot '< grep -v ^$ ./data.dat' #seems more easy just my 2 cents, re, wh |
|
From: David L. <lin...@ie...> - 2011-11-27 22:19:16
|
I agree that would work. However, my data file happens to also have several data sets in it (i.e. blocks of data separated by two blank lines), and I would like to retain that information. Personally I don't quite understand why plotting with boxes should yield discontinuities when crossing a gap in the data. Isn't this kinda lika bug of sorts? On Mon, Nov 14, 2011 at 10:43 PM, Hans-Bernhard Bröker <HBB...@t-...> wrote: > On 14.11.2011 17:23, David Lindelöf wrote: > > [...] > >> plot './data.dat' u (bin($2, 0.2)):(1) smooth frequency >> >> However, the 'data.dat' file has a number of discontinuities in it >> (i.e. blank lines). This causes the output to show several sets of >> histograms, one for each continuous set of data. >> >> Is there any workaround for this? I would like the histogram to show >> the distribution in the whole file, and to ignore discontinuities. > > Then you'll have to get rid of those discontinuities. You can do that > statically or on-the-fly, as a preprocessing step before sending the data to > gnuplot. Something like the following might work: > > plot "< grep -v '^$' data.dat" u (bin($2,0.2)):(1.0) sm freq > > -- :::::::::::::::::::::::::::::::::::::::::::: David Lindelöf, Ph.D. +41 (0)79 415 66 41 or skype:david.lindelof Better Software for Tomorrow's Cities: http://computersandbuildings.com Follow me on Twitter: http://twitter.com/dlindelof |