From fffc156a09a816dce8f62478d2649a03edde6cf4 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Fri, 4 Feb 2011 20:41:32 -0800 Subject: [PATCH] documented another method of generating a self-plotting data file --- README.pod | 46 ++++++++++++++++++++++++++++++++++++++++++++-- bin/feedGnuplot | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/README.pod b/README.pod index c9ca34b..281d9ff 100644 --- a/README.pod +++ b/README.pod @@ -129,8 +129,12 @@ B<.png> currently supported. =head2 Self-plotting data files -This script can be used to create self-plotting data files. A self-plotting, -executable data file C is formatted as +This script can be used to enable self-plotting data files. There are 2 ways of +doing this: with a shebang (#!) or with inline perl data. + +=head3 Self-plotting data with a #! + +A self-plotting, executable data file C is formatted as $ cat data #!/usr/bin/feedGnuplot --lines --points @@ -160,6 +164,44 @@ and that the full path to feedGnuplot must be given. The 127 character limit is a serious limitation, but this can likely be resolved with a kernel patch. I have only tried on Linux 2.6. +=head3 Self-plotting data with perl inline data + +Perl supports storing data and code in the same file. This can also be used to +create self-plotting files: + + $ cat plotdata.pl + #!/usr/bin/perl + use strict; + use warnings; + + open PLOT, "| feedGnuplot --lines --points" or die "Couldn't open plotting pipe"; + while( ) + { + my @xy = split; + print PLOT "@xy\n"; + } + __DATA__ + 2 1 + 4 4 + 6 9 + 8 16 + 10 25 + 12 36 + 14 49 + 16 64 + 18 81 + 20 100 + 22 121 + 24 144 + 26 169 + 28 196 + 30 225 + +This is especially useful if the logged data is not in a format directly +supported by feedGnuplot. Raw data can be stored after the __DATA__ directive, +with a small perl script to manipulate the data into a useable format and send +it to the plotter. + =head2 Further help All the options are described with diff --git a/bin/feedGnuplot b/bin/feedGnuplot index 6e1d4a2..64ad78a 100755 --- a/bin/feedGnuplot +++ b/bin/feedGnuplot @@ -793,8 +793,12 @@ B<.png> currently supported. =head2 Self-plotting data files -This script can be used to create self-plotting data files. A self-plotting, -executable data file C is formatted as +This script can be used to enable self-plotting data files. There are 2 ways of +doing this: with a shebang (#!) or with inline perl data. + +=head3 Self-plotting data with a #! + +A self-plotting, executable data file C is formatted as $ cat data #!/usr/bin/feedGnuplot --lines --points @@ -824,6 +828,44 @@ and that the full path to feedGnuplot must be given. The 127 character limit is a serious limitation, but this can likely be resolved with a kernel patch. I have only tried on Linux 2.6. +=head3 Self-plotting data with perl inline data + +Perl supports storing data and code in the same file. This can also be used to +create self-plotting files: + + $ cat plotdata.pl + #!/usr/bin/perl + use strict; + use warnings; + + open PLOT, "| feedGnuplot --lines --points" or die "Couldn't open plotting pipe"; + while( ) + { + my @xy = split; + print PLOT "@xy\n"; + } + __DATA__ + 2 1 + 4 4 + 6 9 + 8 16 + 10 25 + 12 36 + 14 49 + 16 64 + 18 81 + 20 100 + 22 121 + 24 144 + 26 169 + 28 196 + 30 225 + +This is especially useful if the logged data is not in a format directly +supported by feedGnuplot. Raw data can be stored after the __DATA__ directive, +with a small perl script to manipulate the data into a useable format and send +it to the plotter. + =head2 Further help All the options are described with