2 # genspic2gnuplot - Copyright 2004 Ian Jackson - see below
4 # Reads a `genspic' file on stdin. Takes exactly one arg, <pfx>.
6 # Produces various output files:
7 # <pfx>.gnuplots.sh run this to display results
8 # <pfx>,<Kind><N>.gnuplot-cmd gnuplot script for displaying:
9 # <pfx>,<Kind><N>-<M>.gnuplot-data gnuplot-format input data
10 # <pfx>,gnuplot-fifo working fifo for .gnuplots.sh
12 # <Kind> is Freq or Time (according to the type of analysis)
13 # <N> is the count, starting at 0, of which report this is from gnucap
14 # <M> is the individual column of Y data
18 # There's no easy way to mess with the gnuplot settings.
20 # This whole scheme is very clumsy. There should be a driver program
21 # with command-line option parsing.
23 # This program and its documentation are free software; you can
24 # redistribute them and/or modify them under the terms of the GNU
25 # General Public License as published by the Free Software Foundation;
26 # either version 3, or (at your option) any later version.
28 # This program and its documentation are distributed in the hope that
29 # they will be useful, but WITHOUT ANY WARRANTY; without even the
30 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31 # PURPOSE. See the GNU General Public License for more details.
33 # You should have received a copy of the GNU General Public License along
34 # with this program; if not, consult the Free Software Foundation's
35 # website at www.fsf.org, or the GNU Project website at www.gnu.org.
38 die if $ARGV[0] =~ m/^\-/;
41 $sof= "$ofb.gnuplots.sh";
42 open A, "> $sof" or die $!;
43 system 'chmod','+x',"$sof"; $? and die $?;
54 ($c,@s)= split /\s+/, <STDIN>;
56 ($cplot,$logxy,@columns) = @s;
57 $cplot .= $counter{$cplot}++;
58 unshift @columns, 'x:';
59 @mmm= map { s/^(\w+)\:// or die; $1; } @columns;
60 open S, "> $ofb,$cplot.gnuplot-cmd" or die $!;
66 print S "set logscale xy\n" or die $! if $logxy;
67 print S "set y2tics autofreq\n" or die $! if grep { $_ eq 'y2' } @mmm;
70 for ($yn=1; $yn<=$#columns; $yn++) {
71 open "O$yn", "> $ofb,$cplot-$yn.gnuplot-data" or die $!;
76 foreach $mmm (keys %min) {
77 print S "set ${mmm}range [$min{$mmm}:$max{$mmm}]\n" or die $!;
80 for ($yn=1; $yn<=$#columns; $yn++) {
81 close "O$yn" or die $!;
82 $mmm[$yn] =~ m/^y2?$/ or die "$mmm[$yn]";
83 $axes= $mmm[$yn]; $axes =~ s/^y$/y1/;
86 " '$ofb,$cplot-$yn.gnuplot-data'".
87 " axes x1$axes title '$columns[$yn]'"
91 print S "\n\npause -1\n" or die $!;
93 print A " gnuplot $ofb,$cplot.gnuplot-cmd <\$fi &\n" or die $!;
98 die unless @numbers == @columns;
99 for ($yn=0; $yn<=$#columns; $yn++) {
102 $min{$mmm}= $_ unless exists($min{$mmm}) && $min{$mmm} <= $_;
103 $max{$mmm}= $_ unless exists($max{$mmm}) && $max{$mmm} >= $_;
105 printf {"O$yn"} "%s %s\n", $numbers[0], $_
109 } elsif ($c eq 'F') {
118 printf 'hit return to quit: '
125 print ": generated ; $sof\n" or die $!;
127 # $Id: genspic2gnuplot,v 1.6 2007-09-21 21:21:15 ianmdlvl Exp $