Home > Archive > AWK > July 2006 > plotting from an AWK script using gnuplot
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
plotting from an AWK script using gnuplot
|
|
| KamilCzauz@gmail.com 2006-07-20, 6:56 pm |
| Hey guys,
Ive written an awk script that takes a log file and extracts only the
needed data and i would like to know if it would be possible to plot it
in gnuplot from AWK. My script can write the data into a text file,
and i would like to be able to plot this data. my data looks somehting
like this
12 86.8
14 86.7
16 88.9
18 88.2
20 88.0
..... ....
i would like to use gnuplot to plot the left hand side against the
right hand side. I
dont know much about AWK I/O, so im hoping someone here can really help
me out. I would really like to make this all run inside my awk script,
so that from the bash shell all I have to type is
$gawk -f test.gawk data.dat
and it would produce my plots and save it into a file.
Also i have a variable that i want to use as the file name for the
plot, is this possible?
Please help me:(
Thank you,
Kamil Czauz
| |
| John DuBois 2006-07-20, 6:56 pm |
| In article <1153409908.355731.58100@i42g2000cwa.googlegroups.com>,
<KamilCzauz@gmail.com> wrote:
>Ive written an awk script that takes a log file and extracts only the
>needed data and i would like to know if it would be possible to plot it
>in gnuplot from AWK.
....
>i would like to use gnuplot to plot the left hand side against the
>right hand side. I
>dont know much about AWK I/O, so im hoping someone here can really help
>me out. I would really like to make this all run inside my awk script,
>so that from the bash shell all I have to type is
>$gawk -f test.gawk data.dat
>and it would produce my plots and save it into a file.
See ftp://ftp.armory.com/pub/lib/awk/gnuplot for some general ideas on this.
John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
| |
| KamilCzauz@gmail.com 2006-07-20, 6:56 pm |
| John DuBois wrote:
> See ftp://ftp.armory.com/pub/lib/awk/gnuplot for some general ideas on this.
>
> John
> --
Thnx john, but that really doesnt help me much, im still very 
about how to use gnuplot INSIDE of an awk script, i know how to use it
when launched from the command line, but thats about it.
Thnx and please help
Kamil
| |
| Ed Morton 2006-07-20, 6:56 pm |
| KamilCzauz@gmail.com wrote:
> John DuBois wrote:
>
>
>
> Thnx john, but that really doesnt help me much, im still very 
> about how to use gnuplot INSIDE of an awk script, i know how to use it
> when launched from the command line, but thats about it.
>
> Thnx and please help
>
> Kamil
>
Kamil - I don't think it makes sense to invoke gnuplot inside awk, but
if you want to do that, I suppose you could use the "system()" command.
Normally you either invoke awk from inside gnuplot, or you invoke both
awk and gnuplot from some wrapper script (e.g. UNIX shell). For more
information here's some references I've found useful in the past:
general = http://www.gnuplot.info
intro = http://www.cs.uni.edu/Help/gnuplot
tutorial = http://www.duke.edu/~hpgavin/gnuplot.html
man tool = http://piaf.fesb.hr/cgi-bin/info2html?(gnuplot)gnuplot
newsgrp = comp.graphics.apps.gnuplot
Regards,
Ed.
| |
| KamilCzauz@gmail.com 2006-07-20, 6:56 pm |
| this is what i got so far, it works but i think its a very bad example
of awk programming. Is there anyway to make this simpler/better?
if (tmp==1){
printf("echo \"set term png; set output '%s
(%d,%d).png'; plot
'datapoints'\"|gnuplot", timestring, ActProjId,
ActReceiverId)>"tmpscript";
close("datapoints");
close("tmpscript");
system("chmod +x tmpscript");
system("tmpscript");
system("rm tmpscript");
system("rm datapoints");
tmp=0;
| |
| John DuBois 2006-07-20, 6:56 pm |
| In article <1153417100.978436.11650@m73g2000cwd.googlegroups.com>,
<KamilCzauz@gmail.com> wrote:
>John DuBois wrote:
>
>Thnx john, but that really doesnt help me much, im still very 
>about how to use gnuplot INSIDE of an awk script, i know how to use it
>when launched from the command line, but thats about it.
That's exactly what the lib does.
I've added an example to it.
John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
| |
| KamilCzauz@gmail.com 2006-07-20, 9:56 pm |
| John DuBois wrote:
> That's exactly what the lib does.
> I've added an example to it.
>
> John
can you explain how to use this lib inside an awk script? how would
you invoke this script if i wanna plot a set of data points from a
variable called "data"
| |
| John DuBois 2006-07-21, 6:56 pm |
| In article <1153444742.728918.88100@m79g2000cwm.googlegroups.com>,
<KamilCzauz@gmail.com> wrote:
>John DuBois wrote:
>
>can you explain how to use this lib inside an awk script? how would
>you invoke this script if i wanna plot a set of data points from a
>variable called "data"
You would first include the library into your awk program.
Then, see at the example in the interface description for 'gplot()'.
Where it prints data to files, instead write your own data to a file,
in the format expected by gnuplot. Then call gplot() using your filename.
You might start out by just copying the example into a BEGIN{} block and
running it. Then modify it as neccessary for your purposes.
John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
|
|
|
|
|