diff --git a/lib/PDL/Graphics/Simple.pm b/lib/PDL/Graphics/Simple.pm index f7525f6..54d4218 100644 --- a/lib/PDL/Graphics/Simple.pm +++ b/lib/PDL/Graphics/Simple.pm @@ -768,7 +768,7 @@ $plot_options->synonyms( { }); our $plot_types = { points => { args=>[1,2], ndims=>[1] }, - polylines => { args=>[2], ndims=>[1,2] }, + polylines => { args=>[1,2], ndims=>[1,2] }, lines => { args=>[1,2], ndims=>[1] }, bins => { args=>[1,2], ndims=>[1] }, circles => { args=>[2,3], ndims=>[1] }, @@ -970,6 +970,10 @@ sub _translate_plot { if ($ptn eq 'contours' and @args == 1) { my $cntr_cnt = 9; push @args, zeroes($cntr_cnt)->xlinvals($args[-1]->minmax); + } elsif ($ptn eq 'polylines' and @args == 1) { + barf "Single-arg form of '$ptn' must have dim 0 of 3" + if $args[0]->dim(0) != 3; + @args = ($args[0]->slice('0:1'), $args[0]->slice('(2)')); } elsif (defined($pt->{args}[1])) { # Add an index variable if needed barf "First arg to '$ptn' must have at least $pt->{ndims}[0] dims" if $args[0]->ndims < $pt->{ndims}[0]; diff --git a/t/simple.t b/t/simple.t index c7ab511..3a7808f 100644 --- a/t/simple.t +++ b/t/simple.t @@ -58,8 +58,10 @@ for my $bounds (5, {}, [1..3], [1,1]) { { my @w; local $SIG{__WARN__} = sub {push @w, @_}; eval { PDL::Graphics::Simple::_translate_plot(undef, undef, with=>'lines', pdl(1), pdl(1), pdl(1)) }; like $@, qr/requires 1 or 2 columns/; +eval { PDL::Graphics::Simple::_translate_plot(undef, undef, with=>'fits', pdl(1), pdl(1)) }; +like $@, qr/requires 1 columns/; eval { PDL::Graphics::Simple::_translate_plot(undef, undef, with=>'polylines', pdl(1)) }; -like $@, qr/requires 2 columns/; +like $@, qr/Single-arg/; is "@w", "", "no warnings"; }