Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point limitation for PDL Gnuplot and QT terminal using replot

Tags:

perl

gnuplot

pdl

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.using 101 points

Reducing the number of points (from 101 to 51), 14 lines are plotted. using 51 points

And finally using only 21 points, all 15 lines are displayed.

using 21 points

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).

101 points in a single plot

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)

like image 981
Nemesis Avatar asked Mar 03 '16 20:03

Nemesis


1 Answers

I've opened an issue on PDL::Graphics::Gnuplot - hopefully given Gnuplot is now on 5.4 this will not be a problem!

like image 73
Ed. Avatar answered Oct 22 '22 23:10

Ed.