Skip to content

Commit

Permalink
exception when oplot in multiplot mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Oct 1, 2024
1 parent 1fc7bf8 commit 6f47666
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- exception when oplot in multiplot mode

1.013 2024-09-24
- adjust tests to avoid spurious "UNKNOWN" results

Expand Down
20 changes: 7 additions & 13 deletions lib/PDL/Graphics/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ a single array ref containing (nx, ny). Subsequent calls to plot
send graphics to subsequent locations on the window. The ordering
is always horizontal first, and left-to-right, top-to-bottom.
B<NOTE> for multiplotting: C<oplot> does not work and will cause an
exception. This is a limitation imposed by Gnuplot.
=back
=cut
Expand Down Expand Up @@ -849,8 +852,7 @@ sub _translate_plot {
@$po{keys %$h} = values %$h;
}

my $called_from_imag = $po->{called_from_imag};
delete $po->{called_from_imag};
my $called_from_imag = delete $po->{called_from_imag};

$po = $plot_options->options($po);
$po->{oplot} = 1 if $held;
Expand Down Expand Up @@ -950,7 +952,6 @@ sub _translate_plot {
push @args, shift;
}


##############################
# Most array refs get immediately converted to
# PDLs. But the last argument to a "with=labels" curve
Expand Down Expand Up @@ -1078,6 +1079,7 @@ sub _translate_plot {
sub plot {
my $obj = &_invocant_or_global;
my @args = _translate_plot(@$obj{qw(held keys)}, @_);
barf "Can't oplot in multiplot" if $obj->{params}{multi} and $args[1]{oplot};
$obj->{obj}{keys} = $obj->{keys} = shift @args;
$obj->{obj}->plot(@args);
}
Expand All @@ -1099,16 +1101,8 @@ so that the plot will be overlain on the previous one.
=cut

sub oplot {
my $h;

if(ref($_[$#_]) eq 'HASH') {
$h = $_[$#_];
} else {
$h = {};
push @_, $h;
}
$h->{replot} = 1;

push @_, {} if ref($_[-1]) ne 'HASH';
$_[-1]{oplot} = 1;
plot(@_);
}

Expand Down

0 comments on commit 6f47666

Please sign in to comment.