Simple/PLplot.pm

filter: Statementstmt 14.2% 36 / 253 Branchbran 3.2% 3 / 92 Conditioncond 3.8% 1 / 26 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 38.8% 7 / 18 Podpod 0.0% 0 / 3 totaltotal 11.4% 47 / 409 CC 60 SCAR 55.1
CC
60
Cov
11%
plot
650.0
__ANON__
110.0
new
90.0
CRAP 247.5
« Simple/PGPLOT.pm ↑ Summary
1  
2 ######################################################################
3 ######################################################################
4 ######################################################################
5 ###
6 ###
7 ### PLplot interface to PDL::Graphics::Simple
8 ###
9 ### See the PDL::Graphics::Simple docs for details
10 ###
11 ##
12 #
13  
14 package PDL::Graphics::Simple::PLplot;
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use File::Temp qw/tempfile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Time::HiRes qw/usleep/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use PDL::Options q/iparse/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use PDL;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 our $mod = {
24 shortname => 'plplot',
25 module=>'PDL::Graphics::Simple::PLplot',
26 engine => 'PDL::Graphics::PLplot',
27 synopsis=> 'PLplot (nice plotting, sloooow images)',
28 pgs_api_version=> '1.012',
29 };
30 1 PDL::Graphics::Simple::register( $mod );
31  
32 1 my @DEVICES = qw(
33 qtwidget wxwidgets xcairo xwin wingcc
34 );
35 1 our $guess_filetypes = {
36 ps => ['pscairo','psc', 'psttfc', 'ps'],
37 svg => ['svgcairo','svg','svgqt'],
38 pdf => ['pdfcairo','pdfqt'],
39 png => ['pngcairo','pngqt']
40 };
41 1 our $filetypes;
42  
43 ##########
44 # PDL::Graphics::Simple::PLplot::check
45 # Checker
46  
47 1 ▶sub check {
Subroutine check: called CC=11 SCAR=41.1
Pod undocumented
48 1 my $force = shift;
49 1 ▶ $force = 0 unless(defined($force));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $force 1 0 1
50  
51 1 ▶ return $mod->{ok} unless( $force or !defined($mod->{ok}) );
Branch: 1 branch
BranchTrueFalseTotal
unless $force or not defined $PDL::Graphics::Simple::PLplot::mod->{"ok"} 0 1 1
Condition33%1/3
$force or not defined $PDL::Graphics::Simple::PLplot::mod->{"ok"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$force or not defined $PDL::Graphics::Simple::PLplot::mod->{"ok"}
$force not defined $PDL::Graphics::Simple::PLplot::mod->{"ok"}
Truth table33%1/3
A or not(B)
A= $forceB= not defined $PDL::Graphics::Simple::PLplot::mod->{"ok"}
ABresult
1X1
011
000
52  
53 0 eval { require PDL::Graphics::PLplot; PDL::Graphics::PLplot->import };
54 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 0 1
55 1 $mod->{ok} = 0;
56 1 $mod->{msg} = $@;
57 1 return 0;
58 }
59  
60 # Module loaded OK, now try to extract valid devices from it.
61 0 my $plgDevs = plgDevs();
62 0 $mod->{devices} = {map +($_=>1), keys %$plgDevs};
63  
64 0 ▶ if ( my ($good_dev) = $ENV{PDL_SIMPLE_DEVICE} || grep $mod->{devices}{$_}, @DEVICES ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($good_dev) = $ENV{'PDL_SIMPLE_DEVICE'} || grep($PDL::Graphics::Simple::PLplot::mod->{'devices'}{$_}, @DEVICES)) { } 0 0 0
Condition0%0/3
$ENV{'PDL_SIMPLE_DEVICE'} || grep($PDL::Graphics::Simple::PLplot::mod->{'devices'}{$_}, @DEVICES)
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'PDL_SIMPLE_DEVICE'} || grep($PDL::Graphics::Simple::PLplot::mod->{'devices'}{$_}, @DEVICES)
$ENV{'PDL_SIMPLE_DEVICE'} grep($PDL::Graphics::Simple::PLplot::mod->{'devices'}{$_}, @DEVICES)
Truth table0%0/3
A || B
A= $ENV{'PDL_SIMPLE_DEVICE'}B= grep($PDL::Graphics::Simple::PLplot::mod->{'devices'}{$_}, @DEVICES)
ABresult
1X1
011
000
65 0 $mod->{disp_dev} = $good_dev;
66 } else {
67 0 $mod->{ok} = 0;
68 $mod->{msg} = join("\n\t", "No suitable display device found among:",
69 0 sort keys %{ $mod->{devices} }) . "\n";
70 0 return 0;
71 }
72  
73 0 $filetypes = {};
74 0 for my $k (keys %{$guess_filetypes}) {
75 0 VAL:for my $v ( @{$guess_filetypes->{$k}} ) {
76 0 ▶ if ($mod->{devices}->{$v}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PDL::Graphics::Simple::PLplot::mod->{"devices"}{$v}) 0 0 0
77 0 $filetypes->{$k} = $v;
78 0 last VAL;
79 }
80 }
81 }
82  
83 0 ▶ unless ($filetypes->{ps}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($PDL::Graphics::Simple::PLplot::filetypes->{"ps"}) 0 0 0
84 0 $mod->{ok} = 0;
85 0 $mod->{msg} = "No PostScript found";
86 0 return 0;
87 }
88 0 $mod->{plplot_version} = PDL::Graphics::PLplot::plgver();
89 0 $mod->{ok} = 1;
90 0 return 1;
91 }
92  
93  
94 ##########
95 # PDL::Graphics::Simple::PLplot::new
96 1 our $new_defaults ={
97 size => [8,6,'in'],
98 type => '',
99 output=>'',
100 multi=>undef
101 };
102  
103 0 ▶sub new {
Subroutine new: not called CC=9 SCAR=45.0
Pod undocumented
104 0 my $pkg = shift;
105 0 my $opt_in = shift;
106 0 my $opt = { iparse( $new_defaults, $opt_in ) };
107  
108 # Force a recheck on failure, in case the user fixed PLplot.
109 0 ▶ unless(check()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (check()) 0 0 0
110 0 ▶ die "$mod->{shortname} appears nonfunctional: $mod->{msg}\n" unless(check(1));
Branch: 1 branch
BranchTrueFalseTotal
unless check(1) 0 0 0
111 }
112  
113 # Figure the device name and size to feed to PLplot.
114 0 my $conv_tempfile;
115 my $dev;
116 0 my @params;
117 0 ▶ if ( $opt->{type} =~ m/^i/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'type'} =~ /^i/i) { } 0 0 0
118 ## Interactive devices
119 0 $dev = $mod->{disp_dev};
120 0 ▶ if ($opt->{output}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{"output"}) 0 0 0
121 0 push(@params, FILE=>$opt->{output});
122 }
123 } else {
124 0 my $ext;
125 ## File devices
126 0 ▶ if ( $opt->{output} =~ m/\.(\w{2,4})$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'output'} =~ /\.(\w{2,4})$/) { } 0 0 0
127 0 $ext = $1;
128 } else {
129 0 $ext = 'png';
130 0 $opt->{output} .= ".png";
131 }
132 0 ▶ unless( $filetypes->{$ext} and $mod->{devices}->{$filetypes->{$ext}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PDL::Graphics::Simple::PLplot::filetypes->{$ext} and $PDL::Graphics::Simple::PLplot::mod->{'devices'}{$PDL::Graphics::Simple::PLplot::filetypes->{$ext}}) { } 0 0 0
Condition0%0/3
$PDL::Graphics::Simple::PLplot::filetypes->{$ext} and $PDL::Graphics::Simple::PLplot::mod->{"devices"}{$PDL::Graphics::Simple::PLplot::filetypes->{$ext}}
!ll&&!rl&&r
000
MC/DC0%0/2
$PDL::Graphics::Simple::PLplot::filetypes->{$ext} and $PDL::Graphics::Simple::PLplot::mod->{"devices"}{$PDL::Graphics::Simple::PLplot::filetypes->{$ext}}
$PDL::Graphics::Simple::PLplot::filetypes->{$ext} $PDL::Graphics::Simple::PLplot::mod->{"devices"}{$PDL::Graphics::Simple::PLplot::filetypes->{$ext}}
Truth table0%0/3
A and B
A= $PDL::Graphics::Simple::PLplot::filetypes->{$ext}B= $PDL::Graphics::Simple::PLplot::mod->{"devices"}{$PDL::Graphics::Simple::PLplot::filetypes->{$ext}}
ABresult
0X0
100
111
133 ## Have to set up file conversion
134 0 my($fh);
135 0 ($fh, $conv_tempfile) = tempfile('pgs_plplot_XXXX');
136 0 close $fh;
137 0 unlink $conv_tempfile; # just to be sure...
138 0 $conv_tempfile .= ".ps";
139 0 $dev = $filetypes->{ps};
140 0 push(@params, FILE=>$conv_tempfile);
141 } else {
142 0 $dev = "$filetypes->{$ext}";
143 0 push(@params, FILE=>$opt->{output});
144 }
145 }
146 0 push @params, DEV=>$dev;
147  
148 0 my $size = PDL::Graphics::Simple::_regularize_size($opt->{size},'px');
149 0 push(@params, PAGESIZE => [ @$size[0,1] ]);
150  
151 0 my $me = { opt=>$opt, conv_fn=>$conv_tempfile };
152  
153 0 ▶ if ( defined($opt->{multi}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt->{"multi"}) 0 0 0
154 0 push @params, SUBPAGES => [@{$opt->{multi}}[0,1]];
155 0 $me->{multi_cur} = 0;
156 0 $me->{multi_n} = $opt->{multi}[0] * $opt->{multi}[1];
157 }
158  
159 0 $me->{obj} = my $w = PDL::Graphics::PLplot->new( @params );
160 0 plsstrm($w->{STREAMNUMBER});
161 0 plspause(0);
162 0 return bless $me;
163 }
164  
165 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=3 SCAR=24.8
166 # Make sure X11 windows disappear when destroyed...
167 0 my $me = shift;
168 0 ▶ if( $me->{opt}->{type} =~ m/^i/i and defined($me->{obj}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"opt"}{"type"} =~ /^i/i and defined $me->{"obj"}) 0 0 0
Condition0%0/3
$me->{"opt"}{"type"} =~ /^i/i and defined $me->{"obj"}
!ll&&!rl&&r
000
MC/DC0%0/2
$me->{"opt"}{"type"} =~ /^i/i and defined $me->{"obj"}
$me->{"opt"}{"type"} =~ /^i/i defined $me->{"obj"}
Truth table0%0/3
A and B
A= $me->{"opt"}{"type"} =~ /^i/iB= defined $me->{"obj"}
ABresult
0X0
100
111
169 0 $me->{obj}->close;
170 0 delete $me->{obj};
171 }
172 }
173  
174 # if the value is a string, it's a PLOTTYPE parameter sent to xplot. Otherwise
175 # it's a plotting sub...
176 our $plplot_methods = {
177 lines => 'LINE',
178 0 ▶ bins => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
179 0 my ($me, $ipo, $data, $ppo) = @_;
180 0 my $x = $data->[0];
181 0 my $x1 = $x->range( [[0],[-1]], [$x->dim(0)], 'e' )->average;
182 0 my $x2 = $x->range( [[1],[0]], [$x->dim(0)], 'e' )->average;
183 0 my $newx = pdl($x1,$x2)->mv(-1,0)->clump(2)->sever;
184 0 my $y = $data->[1];
185 0 my $newy = $y->dummy(0,2)->clump(2)->sever;
186 0 $me->{obj}->xyplot($newx, $newy, PLOTTYPE=>'LINE', %{$ppo});
187 },
188 points => 'POINTS',
189 0 ▶ errorbars => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
190 0 my ($me, $ipo, $data, $ppo) = @_;
191 0 $me->{obj}->xyplot(@$data[0,1], %$ppo, YERRORBAR=>$data->[2]*2);
192 },
193 0 ▶ limitbars => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
194 0 my ($me, $ipo, $data, $ppo) = @_;
195 0 $me->{obj}->xyplot($data->[0], 0.5*($data->[2]+$data->[3]), %$ppo,
196 YERRORBAR=>($data->[3]-$data->[2])->abs,
197 PLOTTYPE=>'POINTS', SYMBOLSIZE=>0.0001, %$ppo);
198 0 $me->{obj}->xyplot($data->[0], $data->[1], PLOTTYPE=>'LINE', %$ppo);
199 },
200 0 ▶ contours => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
201 0 my ($me,$ipo,$data,$ppo) = @_;
202 0 my ($vals, $cvals) = @$data;
203 0 my $obj = $me->{obj};
204 0 plsstrm($obj->{STREAMNUMBER});
205 0 $obj->setparm(%$ppo);
206 0 pllsty($ppo->{LINESTYLE});
207 0 ▶ plwidth($ppo->{LINEWIDTH}) if $ppo->{LINEWIDTH};
Branch: 1 branch
BranchTrueFalseTotal
if $ppo->{"LINEWIDTH"} 0 0 0
208 0 my ($nx,$ny) = $vals->dims;
209 0 $obj->_setwindow;
210 0 $obj->_drawlabels;
211 0 my $grid = plAlloc2dGrid($vals->xvals, $vals->yvals);
212 0 plcont($vals, 1, $nx, 1, $ny, $cvals, \&pltr2, $grid);
213 0 plFree2dGrid($grid);
214 },
215 0 ▶ image => sub {
Subroutine __ANON__: not called CC=10 SCAR=47.0
216 0 my ($me,$ipo,$data,$ppo) = @_;
217  
218 # Hammer RGB into greyscale
219 0 ▶ if($data->[2]->dims>2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->[2]->dims > 2) 0 0 0
220 0 $data->[2] = $data->[2]->mv(2,0)->average;
221 }
222  
223 0 my ($immin,$immax) = $data->[2]->minmax;
224 0 ▶ $ppo->{ZRANGE} = [] unless defined($ppo->{ZRANGE});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ppo->{"ZRANGE"} 0 0 0
225 0 ▶ $ppo->{ZRANGE}->[0] = $immin unless defined($ppo->{ZRANGE}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ppo->{"ZRANGE"}[0] 0 0 0
226 0 ▶ $ppo->{ZRANGE}->[1] = $immax unless defined($ppo->{ZRANGE}->[1]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ppo->{"ZRANGE"}[1] 0 0 0
227  
228 0 my $xmin = $data->[0]->min - 0.5 * ($data->[0]->max - $data->[0]->min) / $data->[0]->dim(0);
229 0 my $xmax = $data->[0]->max + 0.5 * ($data->[0]->max - $data->[0]->min) / $data->[0]->dim(0);
230 0 my $ymin = $data->[1]->min - 0.5 * ($data->[1]->max - $data->[1]->min) / $data->[1]->dim(1);
231 0 my $ymax = $data->[1]->max + 0.5 * ($data->[1]->max - $data->[1]->min) / $data->[1]->dim(1);
232 0 ▶ my $min = ($ipo->{crange} and defined($ipo->{crange}->[0])) ? $ipo->{crange}->[0] : $data->[2]->min;
Branch: 1 branch
BranchTrueFalseTotal
$ipo->{'crange'} && defined $ipo->{'crange'}[0] ? : 0 0 0
Condition0%0/3
$ipo->{"crange"} and defined $ipo->{"crange"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$ipo->{"crange"} and defined $ipo->{"crange"}[0]
$ipo->{"crange"} defined $ipo->{"crange"}[0]
Truth table0%0/3
A and B
A= $ipo->{"crange"}B= defined $ipo->{"crange"}[0]
ABresult
0X0
100
111
233 0 ▶ my $max = ($ipo->{crange} and defined($ipo->{crange}->[1])) ? $ipo->{crange}->[1] : $data->[2]->max;
Branch: 1 branch
BranchTrueFalseTotal
$ipo->{'crange'} && defined $ipo->{'crange'}[1] ? : 0 0 0
Condition0%0/3
$ipo->{"crange"} and defined $ipo->{"crange"}[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$ipo->{"crange"} and defined $ipo->{"crange"}[1]
$ipo->{"crange"} defined $ipo->{"crange"}[1]
Truth table0%0/3
A and B
A= $ipo->{"crange"}B= defined $ipo->{"crange"}[1]
ABresult
0X0
100
111
234  
235 0 my $nsteps = 128;
236  
237 0 my $obj = $me->{obj};
238  
239 0 plsstrm($obj->{STREAMNUMBER});
240 0 $obj->setparm(%$ppo);
241 0 my($nx,$ny) = $data->[0]->dims;
242  
243 0 $obj->_setwindow;
244 0 $obj->_drawlabels;
245  
246 0 plcol0(1);
247 plbox ($obj->{XTICK}, $obj->{NXSUB}, $obj->{YTICK}, $obj->{NYSUB},
248 0 $obj->{XBOX}, $obj->{YBOX}); # !!! note out of order call
249  
250 # Set color map
251 0 my $r = (xvals(128)/127)->sqrt;
252 0 my $g = (xvals(128)/127);
253 0 my $b = (xvals(128)/127)**2;
254 0 plscmap1l( 1, xvals(128)/127, $r, $g, $b, ones(128));
255  
256 0 my ($fill_width, $cont_color, $cont_width) = (2, 0, 0);
257 0 my $clevel = ((PDL->sequence($nsteps)*(($max - $min)/($nsteps-1))) + $min);
258 0 my $grid = plAlloc2dGrid($data->[0], $data->[1]);
259 0 plshades( $data->[2], $xmin, $xmax, $ymin, $ymax, $clevel, $fill_width, $cont_color, $cont_width, 0, 0, \&pltr2, $grid );
260 0 plFree2dGrid($grid);
261  
262 0 ▶ if($ipo->{wedge}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipo->{"wedge"}) 0 0 0
263 # Work around PLplot justify bug
264 0 local($obj->{JUST}) = 0;
265 0 $obj->colorkey($data->[2], 'v', VIEWPORT=>[0.93,0.96,0.15,0.85], TITLE=>"");
266 }
267 },
268 0 ▶ circles => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
269 0 my ($me,$ipo,$data,$ppo) = @_;
270 0 my $ang = PDL->xvals(362)*3.14159/180;
271 0 my $c = $ang->cos;
272 0 my $s = $ang->sin;
273 0 $s->slice("361") .= $c->slice("361") .= PDL->pdl(1.1)->acos; # NaN
274 0 my $dr = $data->[2]->flat;
275 0 my $dx = ($data->[0]->flat->slice("*1") + $dr->slice("*1") * $c)->flat;
276 0 my $dy = ($data->[1]->flat->slice("*1") + $dr->slice("*1") * $s)->flat;
277 0 $me->{obj}->xyplot( $dx, $dy, PLOTTYPE=>'LINE',%{$ppo});
278 },
279 0 ▶ polylines => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
280 0 require PDL::ImageND;
281 0 my ($me,$ipo,$data,$ppo) = @_;
282 0 my ($xy, $pen) = @$data;
283 0 my $pi = $pen->eq(0)->which;
284 $me->{obj}->xyplot($_->dog, PLOTTYPE=>'LINE', %$ppo)
285 0 for PDL::ImageND::path_segs($pi, $xy->mv(0,-1));
286 },
287 0 ▶ labels => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
288 0 my ($me, $ipo, $data, $ppo) = @_;
289  
290 # Call xyplot to make sure the axes get set up.
291 0 $me->{obj}->xyplot( pdl(1.1)->asin, pdl(1.1)->asin, %{$ppo} );
292  
293 0 for my $i (0..$data->[0]->dim(0)-1) {
294 0 my $j = 0;
295 0 my $s = $data->[2]->[$i];
296 0 ▶ if ($s =~ s/^([\<\|\> ])//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ s/^([\<\|\> ])//) 0 0 0
297 0 ▶ $j = 1 if($1 eq '>');
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq ">" 0 0 0
298 0 ▶ $j = 0.5 if($1 eq '|');
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq "|" 0 0 0
299 }
300 0 $me->{obj}->text($s, TEXTPOSITION=>[ $data->[0]->at($i), $data->[1]->at($i),
301 1,0,
302 $j
303 ],
304 );
305 }
306 }
307 1 };
308  
309 1 our @colors = qw/BLACK RED GREEN BLUE MAGENTA CYAN YELLOW TURQUOISE PINK AQUAMARINE LIGHTSEAGREEN GOLD2 BROWN/;
310  
311 ##############################
312 # PDL::Graphics::Simple::PLplot::plot
313  
314 0 ▶sub plot {
Subroutine plot: not called CC=25 SCAR=64.8
Pod undocumented
315 0 my $me = shift;
316 0 my $ipo = shift;
317 0 my $ppo = {};
318  
319 0 ▶ $ppo->{TITLE} = $ipo->{title} if(defined($ipo->{title}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $ipo->{"title"} 0 0 0
320 0 ▶ $ppo->{XLAB} = $ipo->{xlabel} if(defined($ipo->{xlabel}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $ipo->{"xlabel"} 0 0 0
321 0 ▶ $ppo->{YLAB} = $ipo->{ylabel} if(defined($ipo->{ylabel}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $ipo->{"ylabel"} 0 0 0
322 0 ▶ $ppo->{ZRANGE} = $ipo->{crange} if(defined($ipo->{crange}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $ipo->{"crange"} 0 0 0
323  
324 0 ▶ unless( $ipo->{oplot} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ipo->{"oplot"}) 0 0 0
325 0 $me->{style} = 0;
326 0 $me->{logaxis} = $ipo->{logaxis};
327 0 plsstrm($me->{obj}{STREAMNUMBER});
328 $me->{multi_cur} %= $me->{multi_n}, $me->{multi_cur}++
329 0 ▶ if $me->{opt}{multi};
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"opt"}{"multi"} 0 0 0
330 0 ▶ pladv($me->{multi_cur} || 1);
Condition0%0/2
$me->{'multi_cur'} || 1
l!l
00
MC/DC0%0/1
$me->{'multi_cur'} || 1
$me->{'multi_cur'}
Truth table0%0/2
A
A= $me->{'multi_cur'}
Aresult
11
00
331 0 ▶ if (!$me->{multi_n} or $me->{multi_cur}==1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $me->{"multi_n"} or $me->{"multi_cur"} == 1) 0 0 0
Condition0%0/3
not $me->{"multi_n"} or $me->{"multi_cur"} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $me->{"multi_n"} or $me->{"multi_cur"} == 1
not $me->{"multi_n"} $me->{"multi_cur"} == 1
Truth table0%0/3
not(A) or B
A= not $me->{"multi_n"}B= $me->{"multi_cur"} == 1
ABresult
1X1
011
000
332 0 ▶ if ($me->{opt}->{type}=~ m/^i/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"opt"}{"type"} =~ /^i/) 0 0 0
333 0 pleop();
334 0 plclear();
335 0 plbop();
336 }
337 }
338 0 ▶ if($ipo->{logaxis} =~ m/x/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipo->{"logaxis"} =~ /x/i) 0 0 0
339 0 $me->{obj}{XBOX} = 'bcnstl';
340 0 $ipo->{xrange} = [ map log10($_), @{$ipo->{xrange}}[0,1] ];
341 }
342 0 ▶ if($ipo->{logaxis} =~ m/y/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipo->{"logaxis"} =~ /y/i) 0 0 0
343 0 $me->{obj}{YBOX} = 'bcnstl';
344 0 $ipo->{yrange} = [ map log10($_), @{$ipo->{yrange}}[0,1] ];
345 }
346 0 $me->{obj}{BOX} = [ @{$ipo->{xrange}}[0,1], @{$ipo->{yrange}}[0,1] ];
347 0 $me->{obj}{VIEWPORT} = [0.1,0.87,0.13,0.82]; # copied from defaults in PLplot.pm. Blech.
348 0 $me->{obj}{JUST} = !!$ipo->{justify};
349 }
350  
351 0 ▶ warn "P::G::S::PLplot: legends not implemented yet for PLplot" if($ipo->{legend});
Branch: 1 branch
BranchTrueFalseTotal
if $ipo->{"legend"} 0 0 0
352  
353 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
354 0 my ($co, @data) = @{shift()};
355 0 my @extra_opts = ();
356 0 ▶ if (defined $co->{style}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $co->{'style'}) { } 0 0 0
357 0 $me->{style} = $co->{style};
358 } else {
359 0 $me->{style}++;
360 }
361 0 $ppo->{COLOR} = $colors[$me->{style}%(@colors)];
362 0 $ppo->{LINESTYLE} = (($me->{style}-1) % 8) + 1;
363 0 ▶ $ppo->{LINEWIDTH} = $co->{width} if $co->{width};
Branch: 1 branch
BranchTrueFalseTotal
if $co->{"width"} 0 0 0
364 0 my $with = $co->{with};
365 0 ▶ if ($with eq 'fits') {
Branch: 1 branch
BranchTrueFalseTotal
if ($with eq "fits") 0 0 0
366 0 ($with, my $new_opts, my $new_img, my @coords) = PDL::Graphics::Simple::_fits_convert($data[0], $ipo);
367 0 $data[-1] = $new_img;
368 0 unshift @data, @coords;
369 0 $ppo->{XLAB} = delete $new_opts->{xlabel};
370 0 $ppo->{YLAB} = delete $new_opts->{ylabel};
371 0 $me->{obj}{BOX} = [ @{$new_opts->{xrange}}[0,1], @{$new_opts->{yrange}}[0,1] ];
372 }
373 die "Unknown curve option 'with $with'!"
374 0 ▶ unless my $plpm = $plplot_methods->{$with};
Branch: 1 branch
BranchTrueFalseTotal
unless my $plpm = $PDL::Graphics::Simple::PLplot::plplot_methods->{$with} 0 0 0
375 0 ▶ $data[0] = $data[0]->log10 if $me->{logaxis} =~ m/x/i;
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"logaxis"} =~ /x/i 0 0 0
376 0 ▶ $data[1] = $data[1]->log10 if $me->{logaxis} =~ m/y/i;
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"logaxis"} =~ /y/i 0 0 0
377 0 ▶ if (ref($plpm) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $plpm eq 'CODE') { } 0 0 0
378 0 $plpm->($me, $ipo, \@data, $ppo);
379 } else {
380 0 $me->{obj}->xyplot(@data,PLOTTYPE=>$plpm,%$ppo);
381 }
382 0 plflush();
383 }
384  
385 0 ▶ $me->{obj}->close if $me->{opt}{type} =~ m/^f/i and !defined $me->{opt}{multi};
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"opt"}{"type"} =~ /^f/i and not defined $me->{"opt"}{"multi"} 0 0 0
Condition0%0/3
$me->{"opt"}{"type"} =~ /^f/i and not defined $me->{"opt"}{"multi"}
!ll&&!rl&&r
000
MC/DC0%0/2
$me->{"opt"}{"type"} =~ /^f/i and not defined $me->{"opt"}{"multi"}
$me->{"opt"}{"type"} =~ /^f/i not defined $me->{"opt"}{"multi"}
Truth table0%0/3
A and not(B)
A= $me->{"opt"}{"type"} =~ /^f/iB= not defined $me->{"opt"}{"multi"}
ABresult
0X0
100
111
386  
387 0 ▶ if ($me->{conv_fn}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"conv_fn"}) 0 0 0
388 0 my $im = rim($me->{conv_fn});
389 0 wim($im->mv(1,0)->slice(':,-1:0:-1'), $me->{opt}{output});
390 0 unlink($me->{conv_fn});
391 }
392 }
393  
394 1 1;
« Simple/PGPLOT.pm ↑ Summary