While using PDL::Graphics::Gnuplot to plot data, I came across a strange effect. It seems, only a limited number of points is plotted at a time using replot
.
Consider the following example (15 lines with 101 points):
use strict;
use warnings;
use PDL;
use PDL::Graphics::Gnuplot qw/gpwin/;
my $win = gpwin('qt', persist => 1);
foreach my $a (1..15) {
my $x = sequence(101)/100;
my $y = $a*$x;
if ($a == 1) {
$win->plot({ linecolor => 'black' }, $x, $y);
}
else {
$win->replot({ linecolor => 'black' }, $x, $y);
}
}
Using this example, only 11 lines are plotted instead of 15.
Reducing the number of points (from 101 to 51), 14 lines are plotted.
And finally using only 21 points, all 15 lines are displayed.
First, I thought only a limited number of lines is plotted, but this is not true since the number of plotted lines depend on the size of the piddles.
Is this a limit of the perl module or of Gnuplot? Is there a way to increase the number of maximum points? It seems to be a problem of Gnuplots qt version. Using 'x11'
as terminal does not show this limitation (I tested 100 lines with 101 points without any problems).
Further, I test the same example without using replot
but in a single plot
.
use strict;
use warnings;
use PDL;
use PDL::Graphics::Gnuplot qw/gpwin/;
my $win = gpwin('qt', persist => 1);
my $x = sequence(101)/100;
my $a = sequence(1,15)+1;
my $y = $x*$a;
$win->plot({ linecolor => 'black' }, $x, $y);
Using this code, everything works fine (even when increasing the number of lines to significantly larger values).
So finally, it seems to be an issue of the replot
functionality of the 'qt'
terminal.
(G N U P L O T Version 4.6 patchlevel 6)