Subject: | [PATCH] Allow *tics to specify start/incr/end for making automatic ranges |
Rather than require the user to specify literal 'labels' values directly, this patch adds the ability to say
xtics => { incr => 10 },
or
xtics => { start => 100, incr => 1, end => 200 },
for example.
--
Paul Evans
Subject: | start-incr-end.patch |
=== modified file 'lib/Chart/Gnuplot.pm'
--- lib/Chart/Gnuplot.pm 2015-02-05 15:57:22 +0000
+++ lib/Chart/Gnuplot.pm 2015-02-05 16:07:50 +0000
@@ -654,6 +654,15 @@
$out .= " scale $$tic{length}" if (defined $$tic{length});
$out .= " rotate by $$tic{rotate}" if (defined $$tic{rotate});
$out .= " offset $$tic{offset}" if (defined $$tic{offset});
+ if (defined $$tic{incr}) {
+ if (defined $$tic{start}) {
+ $out .= " $$tic{start}, $$tic{incr}";
+ $out .= ", $$tic{end}" if (defined $$tic{end});
+ }
+ else {
+ $out .= " $$tic{incr}";
+ }
+ }
$out .= " (". join(',', @{$$tic{labels}}) . ")" if
(defined $$tic{labels});
@@ -2980,6 +2989,9 @@
Supported properties are:
labels : the locations of the tic labels
+ start : the starting value for manually-specified range
+ incr : the increment for manually-specified range
+ end : the ending value for manually-specified range
labelfmt : format of the labels
font : font of the labels
fontsize : font size of the lebals
=== modified file 't/axisTics.t'
--- t/axisTics.t 2015-02-05 15:57:22 +0000
+++ t/axisTics.t 2015-02-05 16:07:50 +0000
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Test::More (tests => 1);
+use Test::More (tests => 2);
BEGIN {use Chart::Gnuplot;}
@@ -31,6 +31,23 @@
ok(&diff($c->{_script}, "axisTics_1.gp") == 0);
}
+{
+ my $c = Chart::Gnuplot->new(
+ output => $temp,
+ xtics => {
+ incr => 10,
+ },
+ ytics => {
+ start => 100,
+ incr => 5,
+ end => 200,
+ },
+ );
+
+ $c->_setChart();
+ ok(&diff($c->{_script}, "axisTics_2.gp") == 0);
+}
+
###################################################################
# Compare two files
=== added file 't/axisTics_2.gp'
--- t/axisTics_2.gp 1970-01-01 00:00:00 +0000
+++ t/axisTics_2.gp 2015-02-05 16:07:50 +0000
@@ -0,0 +1,4 @@
+set terminal postscript enhanced color
+set output "temp.ps"
+set xtics 10
+set ytics 100, 5, 200