Skip to content

Commit

Permalink
Gnuplot rationalise args to gpwin
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Apr 12, 2024
1 parent 193ca5e commit abd22e8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/PDL/Graphics/Simple/Gnuplot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ sub check {
}

my $gpw = eval { gpwin() };
if($@) {
if ($@) {
$mod->{ok} = 0;
$mod->{msg} = $@;
die "PDL::Graphics::Simple: PDL::Graphics::Gnuplot didn't construct properly.\n\t$@";
}
$mod->{valid_terms} = $gpw->{valid_terms};

my $okterm = undef;
for my $term(@disp_terms){
if($mod->{valid_terms}->{$term}) {
for my $term (@disp_terms) {
if ($mod->{valid_terms}{$term}) {
$okterm = $term;
last;
}
}

unless( defined $okterm ) {
unless ( defined $okterm ) {
$mod->{ok} = 0;
my $s = "Gnuplot doesn't seem to support any of the known display terminals:\n they are: (".join(",",@disp_terms).")\n";
$mod->{msg} = $s;
Expand Down Expand Up @@ -135,20 +135,20 @@ sub new {

# Do different things for interactive and file types
if($opt->{type} =~ m/^i/i) {
push(@params, "title"=>$opt->{output}) if(defined($opt->{output}));

push(@params, title=>$opt->{output}) if defined $opt->{output};
# Interactive - try known terminals
if($mod->{itype}) {
push(@params, (persist=>0)) if( ($disp_opts->{$mod->{itype}} // {})->{persist} );
push(@params, (font=>"=16"));
$gpw = gpwin($mod->{itype}, @params, persist=>0, font=>"=16" );
push @params, font=>"=16", dashed=>1;
if (my $try = $mod->{itype}) {
$gpw = gpwin($mod->{itype}, @params,
($disp_opts->{$try} // {})->{persist} ? (persist=>0) : ()
);
no warnings 'once';
print $PDL::Graphics::Gnuplot::last_plotcmd;
} else {
attempt:for my $try( @disp_terms ) {
push(@params, (persist=>0)) if( ($disp_opts->{$try} // {})->{persist} );
push(@params, (font=>"=16"));
eval { $gpw = gpwin($try, @params, persist=>0, font=>"=16",dashed=>1); };
eval { $gpw = gpwin($try, @params,
($disp_opts->{$try} // {})->{persist} ? (persist=>0) : ()
); };
last attempt if($gpw);
}
die "Couldn't start a gnuplot interactive window" unless($gpw);
Expand Down

0 comments on commit abd22e8

Please sign in to comment.