@@ -65,7 +65,7 @@ sub check {
65
65
$mod -> {msg } = $@ ;
66
66
return 0;
67
67
}
68
- if ($PDL::Graphics::Gnuplot::VERSION < $required_PGG_version ) {
68
+ if ($PDL::Graphics::Gnuplot::VERSION < $required_PGG_version ) {
69
69
$mod -> {msg } = sprintf (" PDL::Graphics::Gnuplot was found, but is too old (v%s < v%s ). Ignoring it.\n " ,
70
70
$PDL::Graphics::Gnuplot::VERSION ,
71
71
$required_PGG_version
@@ -138,7 +138,7 @@ sub new {
138
138
my $conv_tempfile = ' ' ;
139
139
140
140
# Do different things for interactive and file types
141
- if ($opt -> {type } =~ m / ^i/ i ) {
141
+ if ($opt -> {type } =~ m / ^i/ i ) {
142
142
push (@params , title => $opt -> {output }) if defined $opt -> {output };
143
143
# Interactive - try known terminals unless PDL_SIMPLE_DEVICE given
144
144
push @params , font => " =16" , dashed => 1;
@@ -156,7 +156,7 @@ sub new {
156
156
eval { $gpw = gpwin($try , @params ,
157
157
($disp_opts -> {$try } // {})-> {persist } ? (persist => 0) : ()
158
158
); };
159
- last attempt if ( $gpw ) ;
159
+ last attempt if $gpw ;
160
160
}
161
161
}
162
162
die " Couldn't start a gnuplot interactive window" unless ($gpw );
@@ -168,7 +168,7 @@ sub new {
168
168
169
169
# Filename extension -- 2-4 characters
170
170
my $ext ;
171
- if ($opt -> {output } =~ m /\. (\w {2,4})$ / ) {
171
+ if ($opt -> {output } =~ m /\. (\w {2,4})$ / ) {
172
172
$ext = $1 ;
173
173
} else {
174
174
$ext = ' .png' ;
@@ -184,22 +184,22 @@ sub new {
184
184
my $ft = $filetypes -> {$ext };
185
185
if (ref $ft eq ' ARRAY' ) {
186
186
try:for my $try (@$ft ) {
187
- if ($mod -> {valid_terms }-> {$try }) {
187
+ if ($mod -> {valid_terms }{$try }) {
188
188
$ft = $try ;
189
189
last try;
190
190
}
191
191
}
192
192
if (ref ($ft )) {
193
193
$ft = undef ;
194
194
}
195
- } elsif (!defined ($mod -> {valid_terms }-> {$ft })) {
195
+ } elsif (!defined ($mod -> {valid_terms }{$ft })) {
196
196
$ft = undef ;
197
197
}
198
198
199
199
# Now $ext has the file type - check if its a supported type. If not, make a
200
200
# tempfilename to hold gnuplot's output.
201
201
unless ( defined ($ft ) ) {
202
- unless ($mod -> {valid_terms }-> { ' pscairo' } or $mod -> {valid_terms }-> { ' postscript' }) {
202
+ unless ($mod -> {valid_terms }{ pscairo } or $mod -> {valid_terms }{ postscript }) {
203
203
die " PDL::Graphics::Simple: $ext isn't a valid output file type for your gnuplot,\n\t and it doesn't support .ps either. Sorry, I give up.\n " ;
204
204
}
205
205
@@ -209,20 +209,20 @@ sub new {
209
209
close $fh ;
210
210
unlink ($conv_tempfile ); # just to be sure;
211
211
$conv_tempfile .= " .ps" ;
212
- $ft = $mod -> {valid_terms }-> { ' pscairo' } ? ' pscairo' : ' postscript' ;
212
+ $ft = $mod -> {valid_terms }{ pscairo } ? ' pscairo' : ' postscript' ;
213
213
}
214
- push ( @params , " output" => ($conv_tempfile || $opt -> {output }) );
215
- push ( @params , " color" => 1 ) if ( $PDL::Graphics::Gnuplot::termTab -> {$ft }-> { ' color' } ) ;
216
- push ( @params , " dashed" => 1 ) if ( $PDL::Graphics::Gnuplot::termTab -> {$ft }-> { ' dashed' } ) ;
214
+ push @params , output => ($conv_tempfile || $opt -> {output });
215
+ push @params , color => 1 if $PDL::Graphics::Gnuplot::termTab -> {$ft }{ color } ;
216
+ push @params , dashed => 1 if $PDL::Graphics::Gnuplot::termTab -> {$ft }{ dashed } ;
217
217
$gpw = gpwin( $ft , @params );
218
218
}
219
219
220
220
221
221
my $me = { opt => $opt , conv_fn => $conv_tempfile , obj => $gpw };
222
222
223
223
# Deal with multiplot setup...
224
- if (defined ($opt -> {multi })) {
225
- $me -> {nplots } = $opt -> {multi }-> [0] * $opt -> {multi }-> [1];
224
+ if (defined ($opt -> {multi })) {
225
+ $me -> {nplots } = $opt -> {multi }[0] * $opt -> {multi }[1];
226
226
$me -> {plot_no } = 0;
227
227
} else {
228
228
$me -> {nplots } = 0;
@@ -265,19 +265,19 @@ our $curve_types = {
265
265
for my $i (0..$data [0]-> dim(0)-1) {
266
266
my $j = " " ;
267
267
my $s = $data [2]-> [$i ];
268
- if ( $s =~ s / ^([\<\>\| ])// ) {
268
+ if ( $s =~ s / ^([\<\>\| ])// ) {
269
269
$j = $1 ;
270
270
}
271
271
272
272
my @spec = (" $s " , at => [$data [0]-> at($i ), $data [1]-> at($i )]);
273
- push ( @spec ," left" ) if ( $j eq ' <' ) ;
274
- push ( @spec ," center" ) if ( $j eq ' |' ) ;
275
- push ( @spec ," right" ) if ( $j eq ' >' ) ;
276
- push ( @{$label_list }, \@spec ) ;
273
+ push @spec ," left" if $j eq ' <' ;
274
+ push @spec ," center" if $j eq ' |' ;
275
+ push @spec ," right" if $j eq ' >' ;
276
+ push @{$label_list }, \@spec ;
277
277
}
278
278
$po -> {label } = $label_list ;
279
279
$co -> {with } = " labels" ;
280
- return [ $co , [$po -> {xrange }-> [0]], [$po -> {yrange }-> [0]], [" " ] ];
280
+ return [ $co , [$po -> {xrange }[0]], [$po -> {yrange }[0]], [" " ] ];
281
281
}
282
282
283
283
};
@@ -299,50 +299,49 @@ sub plot {
299
299
clut => ' sepia' ,
300
300
};
301
301
302
- if ( defined ($ipo -> {legend }) ) {
302
+ if ( defined ($ipo -> {legend }) ) {
303
303
my $legend = " " ;
304
- if ( $ipo -> {legend } =~ m / l/ i ) {
304
+ if ( $ipo -> {legend } =~ m / l/ i ) {
305
305
$legend .= ' left ' ;
306
- } elsif ($ipo -> {legend } =~ m / r/ i ) {
306
+ } elsif ($ipo -> {legend } =~ m / r/ i ) {
307
307
$legend .= ' right ' ;
308
308
} else {
309
309
$legend .= ' center ' ;
310
310
}
311
- if ( $ipo -> {legend } =~ m / t/ i ) {
311
+ if ( $ipo -> {legend } =~ m / t/ i ) {
312
312
$legend .= ' top ' ;
313
- } elsif ( $ipo -> {legend } =~ m / b/ i ) {
313
+ } elsif ( $ipo -> {legend } =~ m / b/ i ) {
314
314
$legend .= ' bottom ' ;
315
315
} else {
316
316
$legend .= ' center ' ;
317
317
}
318
318
$po -> {key } = $legend ;
319
319
}
320
320
321
- $po -> {logscale } = [$ipo -> {logaxis }] if ( $ipo -> {logaxis }) ;
321
+ $po -> {logscale } = [$ipo -> {logaxis }] if $ipo -> {logaxis };
322
322
323
323
unless ($ipo -> {oplot }) {
324
324
$me -> {curvestyle } = 0;
325
325
}
326
326
327
- my @arglist = ( $po ) ;
327
+ my @arglist = $po ;
328
328
329
- for my $block (@_ ) {
329
+ for my $block (@_ ) {
330
330
die " PDL::Graphics::Simple::Gnuplot: undefined curve type $block ->[0]{with}"
331
331
unless my $ct = $curve_types -> { $block -> [0]{with } };
332
- if (ref ($ct ) eq ' CODE' ) {
332
+ if (ref ($ct ) eq ' CODE' ) {
333
333
$block = &$ct ($me , $po , @$block );
334
334
} else {
335
- $block -> [0]-> {with } = $ct ;
335
+ $block -> [0]{with } = $ct ;
336
336
}
337
337
338
338
# Now parse out curve options and deal with line styles...
339
339
my $co = shift @$block ;
340
- my $gco = {};
341
- $gco -> {with } = $co -> {with };
340
+ my $gco = { with => $co -> {with } };
342
341
343
342
unless ($co -> {with } eq ' labels' ) {
344
343
345
- if (defined ( $co -> { style }) and $co -> {style }) {
344
+ if (defined $co -> {style }) {
346
345
$me -> {curvestyle } = $co -> {style };
347
346
} else {
348
347
$me -> {curvestyle }++;
@@ -351,53 +350,44 @@ sub plot {
351
350
$gco -> {linetype } = $me -> {curvestyle };
352
351
}
353
352
354
- if ( defined ($co -> {width }) and $co -> {width } and $co -> {with } !~ m / ^label/ ) {
355
- my $s ;
356
- if ($co -> {with } =~ m / ^points/ ) {
357
- $gco -> {pointsize } = $co -> {width };
358
- }
353
+ if ( $co -> {width } and $co -> {with } !~ m / ^label/ ) {
354
+ $gco -> {pointsize } = $co -> {width } if $co -> {with } =~ m / ^points/ ;
359
355
$gco -> {linewidth } = $co -> {width };
360
356
}
361
- $gco -> {legend } = $co -> {key } if ( defined ( $co -> {key })) ;
357
+ $gco -> {legend } = $co -> {key } if defined $co -> {key };
362
358
363
- push ( @arglist , ( $gco , @$block )) ;
359
+ push @arglist , $gco , @$block ;
364
360
}
365
361
366
- if ($me -> {nplots }) {
362
+ if ($me -> {nplots }) {
367
363
unless ($me -> {plot_no }) {
368
- $me -> {obj }-> multiplot( layout => [$me -> {opt }-> {multi }-> [0], $me -> { opt } -> { multi } -> [ 1]] );
364
+ $me -> {obj }-> multiplot( layout => [@{ $me -> {opt }{multi }}[0, 1]] );
369
365
}
370
366
}
371
367
372
- if ($ipo -> {oplot }) {
373
- delete $po -> {logaxis };
374
- delete $po -> {xrange };
375
- delete $po -> {yrange };
376
- delete $po -> {cbrange };
377
- delete $po -> {justify };
368
+ if ($ipo -> {oplot }) {
369
+ delete @$po {qw( logaxis xrange yrange cbrange justify) };
378
370
$me -> {obj }-> replot(@arglist );
379
371
} else {
380
372
$me -> {obj }-> plot(@arglist );
381
373
}
382
374
383
375
384
- if ($me -> {nplots }) {
376
+ if ($me -> {nplots }) {
385
377
$me -> {plot_no }++;
386
- if ($me -> {plot_no } >= $me -> {nplots }) {
387
- $me -> {obj }-> end_multi() ;
378
+ if ($me -> {plot_no } >= $me -> {nplots }) {
379
+ $me -> {obj }-> end_multi;
388
380
$me -> {plot_no } = 0;
389
-
390
- $me -> {obj }-> close () if ($me -> {opt }-> {type } =~ m / ^f/ i );
391
-
381
+ $me -> {obj }-> close if $me -> {opt }{type } =~ m / ^f/ i ;
392
382
}
393
383
} else {
394
- $me -> {obj }-> close () if ( $me -> {opt }-> {type } =~ m / ^f/ i ) ;
384
+ $me -> {obj }-> close if $me -> {opt }{type } =~ m / ^f/ i ;
395
385
}
396
386
397
- if ($me -> {opt }-> {type } =~ m / ^f/ i and $me -> {conv_fn }) {
398
- print " converting $me ->{conv_fn} to $me ->{opt}-> {output}..." ;
387
+ if ($me -> {opt }{type } =~ m / ^f/ i and $me -> {conv_fn }) {
388
+ print " converting $me ->{conv_fn} to $me ->{opt}{output}..." ;
399
389
$a = rim($me -> {conv_fn });
400
- wim($a -> slice(' -1:0:-1' )-> mv(1,0), $me -> {opt }-> {output });
390
+ wim($a -> slice(' -1:0:-1' )-> mv(1,0), $me -> {opt }{output });
401
391
unlink ($me -> {conv_fn });
402
392
}
403
393
}
0 commit comments