Subject: | How to plot multiple charts in a multi-page PDF |
Date: | Mon, 15 Jun 2015 15:40:10 +0200 |
To: | bug-Chart-Gnuplot [...] rt.cpan.org |
From: | Oliver.Koch [...] Linde-LE.com |
Hi!
Here is simple test script to plot two graphs:
use diagnostics;
use Chart::Gnuplot;
my $Data1 = Chart::Gnuplot::DataSet->new(
func => 'sin(x)',
title => 'sin(x)',
style => 'lines',
);
my $Data2 = Chart::Gnuplot::DataSet->new(
func => 'cos(x)',
title => 'cos(x)',
style => 'lines',
);
my $Chart = Chart::Gnuplot->new(
terminal => 'pdfcairo',
output => 'Test.pdf',
xrange => ["-2*pi", "2*pi"],
title => '$Chart',
);
$Chart->plot2d($Data1);
$Chart->plot2d($Data2);
Unfortunately, the generated output is a single sided PDF with the last
plot ('cos(x)'). The first chart is overwritten.
According to my analysis the reason is that any plot2d() call executes
GnuPlot with "terminal", "output" and "plot". When called the second time,
the first output is overwritten.
Using add2d() for $Data1 did not help.
I miss the possibility to specify terminal and output file once in the
beginning and then plot any number of charts without closing the output
file. This means that execution of GnuPlot must be postponed until all
plot calls are collected.
I used GnuPlot 5.0 patchlevel 0.
Is there any work around available?
Many thanks in advance and
kind regards,
Oliver