Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated updating of a plot fails with gnuplot5 #60

Closed
amba opened this issue Dec 23, 2016 · 6 comments
Closed

Repeated updating of a plot fails with gnuplot5 #60

amba opened this issue Dec 23, 2016 · 6 comments

Comments

@amba
Copy link
Contributor

amba commented Dec 23, 2016

Hi,
I need to continuously update a plot's data, which comes from a measurement setup.
A condensed example would be:

use PDL::Graphics::Gnuplot qw/gpwin/;
use PDL;

my $w = gpwin('qt', persist => 1, raise => 0);

for my $i (2..10000) {
    my $x = sequence($i);
    my $y = $x **2;
    $w->plot($x, $y);
}

With gnuplot5 (Debian, gnuplot 5.0 patchlevel rc2) and the current CPAN version of PDL::Graphics::Gnuplot, I get this error:

simon@buero ~/perl (master)$ ./pdl-gnuplot.pl
WARNING: your gnuplot has a non-numeric patchlevel 'rc2'.  Use with caution.
(warning will not be repeated)
PDL::Graphics::Gnuplot: ERROR: the gnuplot backend issued an error:
gnuplot> et terminal qt  dashed  persist  noraise 
         ^
         line 0: invalid command
 at /home/simon/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/PDL/Graphics/Gnuplot.pm line 7513, <FOO> line 172.
        PDL::Graphics::Gnuplot::_checkpoint(PDL::Graphics::Gnuplot=HASH(0xaf31c0), "main", HASH(0xb022e8)) called at /home/simon/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/PDL/Graphics/Gnuplot.pm line 3112
        PDL::Graphics::Gnuplot::plot(undef, PDL=SCALAR(0x1c973f0), PDL=SCALAR(0x1c55c90)) called at ./pdl-gnuplot.pl line 15

If I resort to gnuplot4, it works fine.

@d-lamb
Copy link
Member

d-lamb commented Dec 23, 2016

I don't think you have demonstrated that it is repeated drawing of a plot that generates the error. Do you get the same error if you just set $i=2 and run the $x=, $y=, and $w->plot lines, or only after a certain number of iterations of that loop? P::G::G passed to gnuplot the command et terminal qt instead of set terminal qt, which made gnuplot complain (correctly) that it didn't understand the command et. My guess is that that this has something to do with the non-numeric patchlevel complaint just above the error--your gnuplot 4 probably doesn't have a non-numeric patchlevel.

How did you install gnuplot? What version of P::G::G are you using, and how did you install it? Did PDL::Graphics::Gnuplot pass make test?

I don't have the qt terminal available, but I was able to successfully run your code above with the wxt terminal on gnuplot 5.0.5 and P::G::G version 2.006001 (i.e., current git master).

@amba
Copy link
Contributor Author

amba commented Dec 24, 2016

The problem seems to only appear with the qt terminal. With x11, svg, png and jpeg the code works fine.
With the qt terminal, each time I run the code, a different number of points gets drawn before it dies.
If I use the PO {tee => 'nobinary'}, this is the output just before it fails:

print "xxxxxxx Synchronizing gnuplot i/o 3504 xxxxxxx"

=========================
==== PDL::Graphics::Gnuplot t=4.0924: Trying to read from gnuplot (suffix main)
==== PDL::Graphics::Gnuplot t=4.0939: Read string 'xxxxxxx Synchronizing gnuplot i/o 3504 xxxxxxx
' from gnuplot main process
==== PDL::Graphics::Gnuplot t=4.0941: Sent to child process (suffix main) 0 bytes==========

=========================
==== PDL::Graphics::Gnuplot t=4.0941: Sent to child process (suffix main) 57 bytes==========


print "xxxxxxx Synchronizing gnuplot i/o 3505 xxxxxxx"

=========================
==== PDL::Graphics::Gnuplot t=4.0942: Trying to read from gnuplot (suffix main)
==== PDL::Graphics::Gnuplot t=4.0943: Read string 'xxxxxxx Synchronizing gnuplot i/o 3505 xxxxxxx
' from gnuplot main process
1169
==== PDL::Graphics::Gnuplot t=4.0950: Sent to child process (suffix main) 64 bytes==========
reset
set terminal qt  dashed  nopersist  noraise 
set palette 

=========================
==== PDL::Graphics::Gnuplot t=4.0950: Sent to child process (suffix main) 57 bytes==========


print "xxxxxxx Synchronizing gnuplot i/o 3506 xxxxxxx"

=========================
==== PDL::Graphics::Gnuplot t=4.0951: Trying to read from gnuplot (suffix main)
==== PDL::Graphics::Gnuplot t=4.0954: Read string '
gnuplot> et terminal qt  dashed  nopersist  noraise 
         ^
         line 0: invalid command

xxxxxxx Synchronizing gnuplot i/o 3506 xxxxxxx
' from gnuplot main process
PDL::Graphics::Gnuplot: ERROR: the gnuplot backend issued an error:
gnuplot> et terminal qt  dashed  nopersist  noraise 
         ^
         line 0: invalid command
 at /home/simon/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/PDL/Graphics/Gnuplot.pm line 7724, <FOO> line 171.
	PDL::Graphics::Gnuplot::_checkpoint(PDL::Graphics::Gnuplot=HASH(0x210f1e8), "main", HASH(0x325bec0)) called at /home/simon/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/PDL/Graphics/Gnuplot.pm line 3172
	PDL::Graphics::Gnuplot::plot(undef, PDL=SCALAR(0x327a568), PDL=SCALAR(0x327a628)) called at ./pdl-gnuplot.pl line 17
==== PDL::Graphics::Gnuplot t=4.0981: Sent to child process (suffix main) 5 bytes==========
exit

=========================

I have no idea what's going wrong :/

@drzowie
Copy link
Collaborator

drzowie commented Feb 23, 2017

It appears that the "reset" is causing gnuplot to lose a character in the newer rc2 version. I'm putting in a workaround that sends an extra newline to the gnuplot. That should work around the issue in your case, while being harmless in other cases. Sorry it took so long to get to this.

@drzowie
Copy link
Collaborator

drzowie commented Feb 23, 2017

I can't reproduce the problem, so I'm leaving this issue open for now.

@amba
Copy link
Contributor Author

amba commented Mar 15, 2017

It looks like this bug is only happening for gnuplot 5.0.0 and 5.0.1.
I've tried several later versions (5.0.2, 5.0.3, 5.0.5) and it worked fine.

For the affected versions, with the "send additional newlines" commit, it still dies:

PDL::Graphics::Gnuplot: ERROR: the gnuplot backend issued an error:
gnuplot> eset
         ^
         line 0: invalid command
 at /home/simon/PDL-Graphics-Gnuplot/lib/PDL/Graphics/Gnuplot.pm line 7746.

I've tried to prefix the reset string with newlines, but it still errored.

@mohawk2
Copy link
Member

mohawk2 commented Apr 13, 2024

Given this is specific to those known versions of Gnuplot, there is not much that we can really do to fix this. Closing.

@mohawk2 mohawk2 closed this as completed Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants