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

Multiplot followed by replot with hardcopy option. #40

Closed
zmughal opened this issue Feb 9, 2015 · 1 comment
Closed

Multiplot followed by replot with hardcopy option. #40

zmughal opened this issue Feb 9, 2015 · 1 comment

Comments

@zmughal
Copy link
Member

zmughal commented Feb 9, 2015

I tried the following, but P::G::G (v2.004) gave me an error about setting hardcopy while in multiplot mode:

Can't set hardcopy while in multiplot mode!

#!/usr/bin/env perl

use strict;
use warnings;

use PDL;
use PDL::Constants qw(PI);
use PDL::Graphics::Gnuplot;

my $w = gpwin(  );
#$w->option( hardcopy => 'a.png' );  # setting hardcopy before multiplot works

my $theta = zeros(200)->xlinvals(0, 6*PI);

$w->multiplot( layout => [2,1] );
$w->plot( { ls => 1, lw => 2 }, $theta, sin($theta) );
$w->plot( { ls => 2, lw => 2 },  $theta, cos($theta) );
$w->end_multi;

$w->replot( hardcopy => 'a.png' );
$w->close;

<>;

It would seem that I shouldn't be in multiplot mode anymore after the call to end_multi(), right?

By the way, this is related to how I'm getting P::G::Gnuplot working with IPerl, but there are still issues with my approach EntropyOrg/p5-Devel-IPerl#29.

@drzowie
Copy link
Collaborator

drzowie commented Feb 9, 2015

I have to admit, replotting and dealing with multiplots has not been a strong priority, and there are some edge cases that aren’t handled very well. The issue that’s going on is that the replot() is replaying the status (including multiplot status) of the last plot. So the object isn’t in multiplot mode when you call replot(), but it switches into multiplot mode as part of the replot operation, since the multiplot flag is part of the stored state. That’s almost certainly a bug — it would be less wrong to just make the last plot, and the actual desired behavior is to keep track of all the last few plots when in multiplot mode, so that a replot will recreate all of them.

Meanwhile, your best bet for making hard copies of multiplots is to simply ignore the replot mechanism altogether: instead, change the output device and reissue the various plot calls.

Making replot/hardcopy work with multiplots requires keeping a list of the last few plot commands, which is doable but more involved than a quick fix.

I’ll gladly implement the solution, but will need a reminder — would you be so kind as to submit this as an Issue in github? (I’d also take a pull request of course :-)

Cheers,
Craig

On Feb 9, 2015, at 1:35 PM, Zaki Mughal [sivoais] [email protected] wrote:

I tried the following, but it gave me an error about setting hardcopy while in multiplot mode:

#!/usr/bin/env perl

use strict;
use warnings;

use PDL;
use PDL::Constants qw(PI);
use PDL::Graphics::Gnuplot;

my $w = gpwin( );
#$w->option( hardcopy => 'a.png' ); # setting hardcopy before multiplot works

my $theta = zeros(200)->xlinvals(0, 6*PI);

$w->multiplot( layout => [2,1] );
$w->plot( { ls => 1, lw => 2 }, $theta, sin($theta) );
$w->plot( { ls => 2, lw => 2 }, $theta, cos($theta) );
$w->end_multi;

$w->replot( hardcopy => 'a.png' );
$w->close;

<>;
It would seem that I shouldn't be in multiplot mode anymore after the call to end_multi(), right?

By the way, this is related to how I'm getting P::G::Gnuplot working with IPerl, but there are still issues with my approach EntropyOrg/p5-Devel-IPerl#29 EntropyOrg/p5-Devel-IPerl#29.


Reply to this email directly or view it on GitHub #40.

@drzowie drzowie closed this as completed May 23, 2016
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

2 participants