From f3308007c0ac78fa4b0a8ad7875e0144c840d07f Mon Sep 17 00:00:00 2001 From: hjp Date: Wed, 25 Oct 2006 08:52:00 +0000 Subject: [PATCH] Added --log-y option to tsplot and a test case. --- t/2scripts.t | 12 +++++++++++- tsplot | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/t/2scripts.t b/t/2scripts.t index 638f61f..ba7f342 100755 --- a/t/2scripts.t +++ b/t/2scripts.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 7; +use Test::More tests => 11; my $ps1=`./blib/script/tsplot --output_format ps t/1.data`; ok($ps1, 'Postscript output of tsplot is not empty'); @@ -21,4 +21,14 @@ $ps2 =~ s/^%%Title: .*//m; $ps2 =~ s/^%%CreationDate: .*//m; ok($ps1 eq $ps2, 'output of tsplot and tsplotv are identical'); +my $ps3=`./blib/script/tsplot --output_format ps --log_y t/1.data`; +ok($ps3, 'Postscript output of tsplot is not empty'); +ok($ps3 !~ m/\( 0\) Rshow/, 'Postscript output of tsplot doesn\'t contain marker "0"'); +ok($ps3 =~ m/\( 1\) Rshow/, 'Postscript output of tsplot contains marker "1"'); +ok($ps3 =~ m/\( 10\) Rshow/, 'Postscript output of tsplot contains marker "10"'); + +my $fh; +open($fh, ">", "t/$$.lin.ps"); print $fh $ps1; close($fh); +open($fh, ">", "t/$$.log.ps"); print $fh $ps3; close($fh); + #vim:tw=0 diff --git a/tsplot b/tsplot index 0135625..05a2e02 100755 --- a/tsplot +++ b/tsplot @@ -3,8 +3,46 @@ use strict; use TimeSeries; use Getopt::Long; +=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 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 my $output_format ='png'; -GetOptions('output_format|output-format=s' => \$output_format) +my $log_y =0; +GetOptions('output_format|output-format=s' => \$output_format, + 'log_y|log-y' => \$log_y, + ) or die "Usage: $0 [--output_format format] [files...]\n"; @@ -21,6 +59,7 @@ while (<>) { my ($timestamp, @values) = split(); $ts->add_timestring($timestamp, @values); } +$ts->log_y($log_y); my $g = $ts->plot(); print $g