2003-08-08 15:01:59 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
use strict;
|
|
|
|
use TimeSeries;
|
2006-08-29 10:14:27 +02:00
|
|
|
use Getopt::Long;
|
|
|
|
|
2006-10-25 10:52:00 +02:00
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
tsplot - plot time series in column format
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
tsplotv
|
|
|
|
[--legend-position pos]
|
|
|
|
[--output-format format ]
|
|
|
|
[--stacked]
|
|
|
|
[--style style]
|
|
|
|
[file ...]
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
This program expects time series data in column format, I.e.,
|
|
|
|
each line contains a timestamp and the values for each series, except
|
|
|
|
the first one which contains the column headers, which are used for the
|
|
|
|
legend. Columns are separated by any amount of whitespace.
|
|
|
|
|
|
|
|
The default legend position is "top right", same as with gnuplot.
|
|
|
|
Another frequently useful position (especially if you have lots of series)
|
|
|
|
is "below. Note that positions which consist of several world (such as
|
|
|
|
"top right" need to be passed to tsplotv as a single argument, so the
|
|
|
|
space needs to be hidden from the shell by use of quotes or a backslash.
|
|
|
|
|
|
|
|
The default output format is "png", the default style is "lines".
|
|
|
|
|
|
|
|
See L<TimeSeries> for a description of possible legend positions,
|
|
|
|
output formats, and styles.
|
|
|
|
|
|
|
|
The --stacked option causes the time series to be stacked on top of each
|
|
|
|
other.
|
|
|
|
|
|
|
|
=cut
|
2006-08-29 10:14:27 +02:00
|
|
|
my $output_format ='png';
|
2006-10-25 10:52:00 +02:00
|
|
|
my $log_y =0;
|
|
|
|
GetOptions('output_format|output-format=s' => \$output_format,
|
|
|
|
'log_y|log-y' => \$log_y,
|
|
|
|
)
|
2006-08-29 10:14:27 +02:00
|
|
|
or die "Usage: $0 [--output_format format] [files...]\n";
|
|
|
|
|
2003-08-08 15:01:59 +02:00
|
|
|
|
2006-01-02 16:18:46 +01:00
|
|
|
binmode STDOUT, ':raw';
|
|
|
|
|
2006-08-29 10:14:27 +02:00
|
|
|
my $ts = TimeSeries->new(output_format => $output_format);
|
2003-08-08 15:01:59 +02:00
|
|
|
while (<>) {
|
|
|
|
my @legend = split;
|
|
|
|
shift @legend; # first must be for timestamp
|
|
|
|
$ts->legend(@legend);
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
while (<>) {
|
|
|
|
my ($timestamp, @values) = split();
|
|
|
|
$ts->add_timestring($timestamp, @values);
|
|
|
|
}
|
2006-10-25 10:52:00 +02:00
|
|
|
$ts->log_y($log_y);
|
2003-08-08 15:01:59 +02:00
|
|
|
|
|
|
|
my $g = $ts->plot();
|
|
|
|
print $g
|