Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use Data::Dumper;
- use Getopt::Long;
- #...................................................................
- # Config
- #...................................................................
- my $input;
- my $output;
- my $title;
- my $ylabel;
- GetOptions(
- "input=s" => \$input,
- "output=s" => \$output,
- "title=s" => \$title,
- "ylabel=s" => \$ylabel,
- );
- #print "input is [$input]", "\n";
- #print "output is [$output]", "\n";
- #print "title is [$title]", "\n";
- # Start of the contents for the gnuplot (.gp) file
- my $file_gp=<<EOF;
- set terminal png size 800 600
- set output "$output"
- set xtics nomirror rotate -90
- set xlabel "DateTime"
- set ylabel "$ylabel"
- set decimal locale
- set format y "%'g"
- set title "$title"
- set key rmargin
- EOF
- #print $file_gp;
- #...................................................................
- # Read Data from input file, determine number of index sets and their SeriesName
- #...................................................................
- my %series;
- open my $fh_in, '<', "$input" or die "cannot open $input: $!\n";
- while (my $line = <$fh_in>) {
- next unless ($line =~ /\#Series=/);
- my ($series, $idx) = $line =~ /Series=(\S+) Index=(\d+)/;
- # print $line;
- # print "Series is [$series], Index is [$idx]\n";
- $series{$idx} = $series;
- }
- close $fh_in;
- #print Dumper(\%series), "\n";
- #...................................................................
- # Create the `plot' statement based on the different series
- #...................................................................
- my @series;
- foreach my $idx (sort keys %series) {
- my $str = sprintf('"%s" index %s using 3:xtic(2) title "%s" with lines', $input, $idx, $series{$idx});
- # print $str, "\n";
- push @series, $str;
- }
- #print Dumper(\@series), "\n";
- $file_gp .= "plot " . join(", \\\n", @series) . "\n";
- print $file_gp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement