Skip to content

Commit 4a33212

Browse files
committed
doc, test, fix that style curve option can be 0
1 parent 86e9c16 commit 4a33212

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

README.pod

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ number supported by the backend. The styles are generally defined by
467467
a mix of color and dash pattern, but the particular color and dash
468468
pattern depend on the engine in use. The first 30 styles are
469469
guaranteed to be distinguishable. This is useful to produce, e.g.,
470-
multiple traces with the same style.
470+
multiple traces with the same style. C<0> is a valid value.
471471

472472
=back
473473

lib/PDL/Graphics/Simple.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ number supported by the backend. The styles are generally defined by
628628
a mix of color and dash pattern, but the particular color and dash
629629
pattern depend on the engine in use. The first 30 styles are
630630
guaranteed to be distinguishable. This is useful to produce, e.g.,
631-
multiple traces with the same style.
631+
multiple traces with the same style. C<0> is a valid value.
632632
633633
=back
634634

lib/PDL/Graphics/Simple/PGPLOT.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ sub plot {
234234
while (@_) {
235235
my ($co, @data) = @{shift()};
236236
my @extra_opts = ();
237-
if ( defined($co->{style}) and $co->{style} ) {
238-
$me->{curvestyle} = int($co->{style});
237+
if ( defined $co->{style} ) {
238+
$me->{curvestyle} = int($co->{style}) + 1;
239239
} else {
240240
$me->{curvestyle}++;
241241
}

lib/PDL/Graphics/Simple/PLplot.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ sub plot {
330330
while (@_) {
331331
my ($co, @data) = @{shift()};
332332
my @extra_opts = ();
333-
if ( $co->{style}) {
333+
if (defined $co->{style}) {
334334
$me->{style} = $co->{style};
335335
} else {
336336
$me->{style}++;

lib/PDL/Graphics/Simple/Prima.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ sub plot {
506506
my $co = shift @$block;
507507

508508
# Parse out curve style (for points type selection)
509-
if ($co->{style}) {
509+
if (defined $co->{style}) {
510510
$me->{curvestyle} = $co->{style};
511511
} else {
512512
$me->{curvestyle}++;

t/simple.t

+9-9
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ for my $engine (@engines) {
156156
# Simple line & bin plot
157157
{
158158
my @args = PDL::Graphics::Simple::_translate_plot(@$w{qw(held keys)},
159-
with=>'line', $x10, $x10sqrt,
160-
with=>'line', $x10, $x10_12,
159+
with=>'line', style=>0, $x10, $x10sqrt,
160+
with=>'line', style=>0, $x10, $x10_12,
161161
with=>'bins', $x10, $sin10,
162162
{title=>"PDL: $engine engine, line & bin plots"}
163163
);
@@ -173,11 +173,11 @@ is_deeply \@args, [
173173
'xrange' => [ 0, 9 ],
174174
},
175175
[
176-
{ 'key' => undef, 'style' => undef, 'width' => undef, 'with' => 'lines' },
176+
{ 'key' => undef, 'style' => 0, 'width' => undef, 'with' => 'lines' },
177177
$x10, $x10sqrt,
178178
],
179179
[
180-
{ 'key' => undef, 'style' => undef, 'width' => undef, 'with' => 'lines' },
180+
{ 'key' => undef, 'style' => 0, 'width' => undef, 'with' => 'lines' },
181181
$x10, $x10_12,
182182
],
183183
[
@@ -186,9 +186,9 @@ is_deeply \@args, [
186186
]
187187
];
188188
}
189-
eval { $w->plot(with=>'line', $x10, $x10sqrt,
190-
with=>'line', $x10, $x10_12,
191-
with=>'bins', $sin10,
189+
eval { $w->plot(with=>'line', style=>0, $x10, $x10sqrt,
190+
with=>'line', style=>0, $x10, $x10_12,
191+
with=>'bins', style=>3, $sin10,
192192
{title=>"PDL: $engine engine, line & bin plots"}),
193193
};
194194
is($@, '', "plot succeeded\n");
@@ -364,8 +364,8 @@ is_deeply \@args, [
364364

365365
ask_yn qq{
366366
Testing $engine engine: You should see in a 3x2 grid:
367-
1) 2 superposed line plots and a bin plot, with x range from 0 to 9 and
368-
yrange from 0 to 9. The three plots should have different line styles.
367+
1) 2 superposed line plots with same style and a bin plot with different,
368+
with x range from 0 to 9 and yrange from 0 to 9.
369369
2) error bars (symmetric relative to each plotted point) and limit bars
370370
(asymmetric about each plotted point).
371371
3) a radial 11x11 "target" image and some superimposed "circles".

0 commit comments

Comments
 (0)