added method and option yrange.
fixed postscript test (probably broken because of new gnuplot version)
This commit is contained in:
parent
67a3bb656e
commit
4e7a5cd120
|
@ -33,7 +33,7 @@ use HTTP::Date qw(parse_date);
|
||||||
use Time::Local qw(timegm_nocheck);
|
use Time::Local qw(timegm_nocheck);
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
our $VERSION = do { my @r=(q$Revision: 1.20 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
our $VERSION = do { my @r=(q$Revision: 1.21 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
||||||
|
|
||||||
our $debug;
|
our $debug;
|
||||||
|
|
||||||
|
@ -276,6 +276,22 @@ sub finalresolution {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=head2 yrange([$ymin, $ymax])
|
||||||
|
|
||||||
|
Set the y range. If either $ymin or $ymax is undef it is automatically
|
||||||
|
determined.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub yrange {
|
||||||
|
my ($self, $ymin, $ymax) = @_;
|
||||||
|
if (@_ == 3) {
|
||||||
|
$self->{yrange} = [ $ymin, $ymax ];
|
||||||
|
}
|
||||||
|
return $self->{yrange} ? @{ $self->{yrange} } : ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=head2 dstcorr $time [, $period]
|
=head2 dstcorr $time [, $period]
|
||||||
|
|
||||||
|
@ -358,6 +374,7 @@ sub plot {
|
||||||
print $ctlfh "set log y\n" if ($self->{log_y});
|
print $ctlfh "set log y\n" if ($self->{log_y});
|
||||||
print $ctlfh "set key $self->{legend_position}\n" if ($self->{legend_position});
|
print $ctlfh "set key $self->{legend_position}\n" if ($self->{legend_position});
|
||||||
print $ctlfh "set datafile missing '?'\n";
|
print $ctlfh "set datafile missing '?'\n";
|
||||||
|
print $ctlfh "set yrange [", $self->{yrange}[0] // "*", ":", $self->{yrange}[1] // "*", "]\n";
|
||||||
|
|
||||||
my $firsttime = $self->{data}[0][0];
|
my $firsttime = $self->{data}[0][0];
|
||||||
my $lasttime = $self->{data}[$#{$self->{data}}][0];
|
my $lasttime = $self->{data}[$#{$self->{data}}][0];
|
||||||
|
|
16
t/3missing.t
16
t/3missing.t
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Test::More tests => 3;
|
use Test::More tests => 4;
|
||||||
|
|
||||||
BEGIN { use_ok( 'TimeSeries' ); }
|
BEGIN { use_ok( 'TimeSeries' ); }
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ my $p = $ts->plot();
|
||||||
# open(my $fh, '>:raw', "t/3missing.ps");
|
# open(my $fh, '>:raw', "t/3missing.ps");
|
||||||
# print $fh $p;
|
# print $fh $p;
|
||||||
# close($fh);
|
# close($fh);
|
||||||
my $t = "
|
my $t1 = "
|
||||||
LT0
|
LT0
|
||||||
6607 4807 M
|
6607 4807 M
|
||||||
303 0 V
|
303 0 V
|
||||||
|
@ -35,17 +35,15 @@ LT0
|
||||||
4823 2940 M
|
4823 2940 M
|
||||||
5927 4920 L
|
5927 4920 L
|
||||||
7030 960 L
|
7030 960 L
|
||||||
1.000 UL
|
";
|
||||||
LTb
|
|
||||||
410 960 M
|
my $t2 = "
|
||||||
6620 0 V
|
6620 0 V
|
||||||
0 3960 V
|
0 3960 V
|
||||||
-6620 0 V
|
-6620 0 V
|
||||||
410 960 L
|
|
||||||
1.000 UP
|
|
||||||
stroke
|
|
||||||
";
|
";
|
||||||
ok(index($p, $t) != -1, 'postscript output looks ok');
|
ok(index($p, $t1) != -1, 'postscript output contains line');
|
||||||
|
ok(index($p, $t2) != -1, 'postscript output contains box');
|
||||||
|
|
||||||
#vim:tw=0
|
#vim:tw=0
|
||||||
|
|
||||||
|
|
5
tsplot
5
tsplot
|
@ -17,6 +17,7 @@ tsplotv
|
||||||
[--style style]
|
[--style style]
|
||||||
[--time_t]
|
[--time_t]
|
||||||
[--tsv]
|
[--tsv]
|
||||||
|
[--yrange min max]
|
||||||
[file ...]
|
[file ...]
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
@ -52,13 +53,16 @@ my $time_t =0;
|
||||||
my $style = "lines";
|
my $style = "lines";
|
||||||
my $tsv = 0;
|
my $tsv = 0;
|
||||||
my $stacked = 0;
|
my $stacked = 0;
|
||||||
|
my @yrange;
|
||||||
my $keeptempfiles;
|
my $keeptempfiles;
|
||||||
|
|
||||||
GetOptions('output_format|output-format=s' => \$output_format,
|
GetOptions('output_format|output-format=s' => \$output_format,
|
||||||
'log_y|log-y' => \$log_y,
|
'log_y|log-y' => \$log_y,
|
||||||
'time_t' => \$time_t,
|
'time_t' => \$time_t,
|
||||||
'style:s' => \$style,
|
'style:s' => \$style,
|
||||||
'tsv' => \$tsv,
|
'tsv' => \$tsv,
|
||||||
'stacked' => \$stacked,
|
'stacked' => \$stacked,
|
||||||
|
'yrange:s{2}' => \@yrange,
|
||||||
'keeptempfiles' => \$keeptempfiles,
|
'keeptempfiles' => \$keeptempfiles,
|
||||||
)
|
)
|
||||||
or pod2usage(verbose => 0);
|
or pod2usage(verbose => 0);
|
||||||
|
@ -88,6 +92,7 @@ while (<>) {
|
||||||
$ts->log_y($log_y);
|
$ts->log_y($log_y);
|
||||||
$ts->style($style);
|
$ts->style($style);
|
||||||
$ts->stacked($stacked);
|
$ts->stacked($stacked);
|
||||||
|
$ts->yrange(@yrange);
|
||||||
|
|
||||||
my $g = $ts->plot();
|
my $g = $ts->plot();
|
||||||
print $g
|
print $g
|
||||||
|
|
Loading…
Reference in New Issue