Simple/Gnuplot.pm

filter: Statementstmt 16.9% 36 / 213 Branchbran 2.5% 3 / 116 Conditioncond 3.5% 1 / 28 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 3 totaltotal 12.1% 47 / 388 CC 78 SCAR 64.1
CC
78
Cov
11%
new
992.0
plot
812.0
check
64.9
CRAP 607.7
« Simple.pm ↑ Summary Simple/Prima.pm »
1 ######################################################################
2 ######################################################################
3 ######################################################################
4 ###
5 ###
6 ### Gnuplot backend for PDL::Graphics:Simple
7 ###
8 ### See the PDL::Graphics::Simple docs for details
9 ###
10 ##
11 #
12 package PDL::Graphics::Simple::Gnuplot;
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use File::Temp qw/tempfile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use PDL::Options q/iparse/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use PDL;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use PDL::ImageND; # for polylines
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 our $required_PGG_version = 1.5;
21  
22 1 our $mod = {
23 shortname => 'gnuplot',
24 module=>'PDL::Graphics::Simple::Gnuplot',
25 engine => 'PDL::Graphics::Gnuplot',
26 synopsis=> 'Gnuplot 2D/3D (versatile; beautiful output)',
27 pgs_api_version=> '1.012',
28 };
29 1 PDL::Graphics::Simple::register( $mod );
30  
31 1 our $filetypes = {
32 ps => ['pscairo','postscript'],
33 dxf => 'dxf',
34 png => ['pngcairo','png'],
35 pdf => ['pdfcairo','pdf'],
36 txt => 'dumb',
37 jpg => 'jpeg',
38 svg => 'svg',
39 gif => 'gif'
40 };
41  
42 1 our @disp_terms = qw/ qt wxt x11 aqua windows /;
43 1 our $disp_opts = {
44 wxt=>{persist=>1},
45 x11=>{persist=>1},
46 aqua=>{persist=>0},
47 windows=>{persist=>0}
48 };
49  
50 ##########
51 # PDL::Graphics::Simple::Gnuplot::check
52 # Checker
53 1 ▶sub check {
Subroutine check: called CC=11 SCAR=41.7
Pod undocumented
54 1 my $force = shift;
55 1 ▶ $force = 0 unless(defined($force));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $force 1 0 1
56  
57 1 ▶ return $mod->{ok} unless( $force or !defined($mod->{ok}) );
Branch: 1 branch
BranchTrueFalseTotal
unless $force or not defined $PDL::Graphics::Simple::Gnuplot::mod->{"ok"} 0 1 1
Condition33%1/3
$force or not defined $PDL::Graphics::Simple::Gnuplot::mod->{"ok"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$force or not defined $PDL::Graphics::Simple::Gnuplot::mod->{"ok"}
$force not defined $PDL::Graphics::Simple::Gnuplot::mod->{"ok"}
Truth table33%1/3
A or not(B)
A= $forceB= not defined $PDL::Graphics::Simple::Gnuplot::mod->{"ok"}
ABresult
1X1
011
000
58  
59 # Eval PDL::Graphics::Gnuplot. Require relatively recent version.
60 # We don't specify the version in the 'use', so we can issue a
61 # warning on an older version.
62 0 eval { require PDL::Graphics::Gnuplot; PDL::Graphics::Gnuplot->import; };
63 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 0 1
64 1 $mod->{ok} = 0;
65 1 $mod->{msg} = $@;
66 1 return 0;
67 }
68 0 ▶ if ($PDL::Graphics::Gnuplot::VERSION < $required_PGG_version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PDL::Graphics::Gnuplot::VERSION < $PDL::Graphics::Simple::Gnuplot::required_PGG_version) 0 0 0
69 0 $mod->{msg} = sprintf("PDL::Graphics::Gnuplot was found, but is too old (v%s < v%s). Ignoring it.\n",
70 $PDL::Graphics::Gnuplot::VERSION,
71 $required_PGG_version
72 );
73 0 $mod->{ok} = 0;
74 0 return 0;
75 }
76  
77 0 my $gpw = eval { gpwin() };
78 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
79 0 $mod->{ok} = 0;
80 0 $mod->{msg} = $@;
81 0 die "PDL::Graphics::Simple: PDL::Graphics::Gnuplot didn't construct properly.\n\t$@";
82 }
83 0 $mod->{valid_terms} = $gpw->{valid_terms};
84  
85 0 my $okterm = undef;
86 0 ▶ if ($ENV{PDL_SIMPLE_DEVICE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PDL_SIMPLE_DEVICE'}) { } 0 0 0
87 0 $okterm = 1;
88 } else {
89 0 for my $term (@disp_terms) {
90 0 ▶ if ($mod->{valid_terms}{$term}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{$term}) 0 0 0
91 0 $okterm = $term;
92 0 last;
93 }
94 }
95 }
96  
97 0 ▶ unless ( defined $okterm ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $okterm) 0 0 0
98 0 $mod->{ok} = 0;
99 0 my $s = "Gnuplot doesn't seem to support any of the known display terminals:\n they are: (".join(",",@disp_terms).")\n";
100 0 $mod->{msg} = $s;
101 0 die "PDL::Graphics::Simple: $s";
102 }
103 0 $mod->{gp_version} = $PDL::Graphics::Gnuplot::gp_version;
104 0 $mod->{ok} = 1;
105 0 return 1;
106 }
107  
108  
109 ##########
110 # PDL::Graphics::Simple::Gnuplot::new
111 # Constructor
112 1 our $new_defaults = {
113 size => [6,4.5,'in'],
114 type => '',
115 output => '',
116 multi=>undef
117 };
118  
119  
120 0 ▶sub new {
Subroutine new: not called CC=31 SCAR=69.0
Pod undocumented
121 0 my $class = shift;
122 0 my $opt_in = shift;
123 0 ▶ $opt_in = {} unless(defined($opt_in));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt_in 0 0 0
124 0 my $opt = { iparse( $new_defaults, $opt_in ) };
125 0 my $gpw;
126  
127 # Force a recheck on failure, in case the user fixed gnuplot.
128 # Also loads PDL::Graphics::Gnuplot.
129 0 ▶ unless(check()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (check()) 0 0 0
130 0 ▶ die "$mod->{shortname} appears nonfunctional: $mod->{msg}\n" unless(check(1));
Branch: 1 branch
BranchTrueFalseTotal
unless check(1) 0 0 0
131 }
132  
133 # Generate the @params array to feed to gnuplot
134 0 my @params = ();
135 0 push( @params, "size" => $opt->{size} );
136  
137 # tempfile gets set if we need to write to a temporary file for image conversion
138 0 my $conv_tempfile = '';
139  
140 # Do different things for interactive and file types
141 0 ▶ if ($opt->{type} =~ m/^i/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'type'} =~ /^i/i) { } 0 0 0
142 0 ▶ push(@params, title=>$opt->{output}) if defined $opt->{output};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{"output"} 0 0 0
143 # Interactive - try known terminals unless PDL_SIMPLE_DEVICE given
144 0 push @params, font=>"=16", dashed=>1;
145 0 ▶ if (my $try = $mod->{itype}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $try = $PDL::Graphics::Simple::Gnuplot::mod->{'itype'}) { } 0 0 0
146 $gpw = gpwin($mod->{itype}, @params,
147 0 ▶ ($disp_opts->{$try} // {})->{persist} ? (persist=>0) : ()
Branch: 1 branch
BranchTrueFalseTotal
+($PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {})->{'persist'} ? : 0 0 0
Condition0%0/2
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
l!l
00
MC/DC0%0/1
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Truth table0%0/2
A
A= $PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Aresult
11
00
148 );
149 } else {
150 0 ▶ if (my $try = $ENV{PDL_SIMPLE_DEVICE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $try = $ENV{'PDL_SIMPLE_DEVICE'}) { } 0 0 0
151 $gpw = gpwin($try, @params,
152 0 ▶ ($disp_opts->{$try} // {})->{persist} ? (persist=>0) : ()
Branch: 1 branch
BranchTrueFalseTotal
+($PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {})->{'persist'} ? : 0 0 0
Condition0%0/2
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
l!l
00
MC/DC0%0/1
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Truth table0%0/2
A
A= $PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Aresult
11
00
153 );
154 } else {
155 0 attempt:for my $try( @disp_terms ) {
156 0 eval { $gpw = gpwin($try, @params,
157 0 ▶ ($disp_opts->{$try} // {})->{persist} ? (persist=>0) : ()
Branch: 1 branch
BranchTrueFalseTotal
+($PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {})->{'persist'} ? : 0 0 0
Condition0%0/2
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
l!l
00
MC/DC0%0/1
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try} // {}
$PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Truth table0%0/2
A
A= $PDL::Graphics::Simple::Gnuplot::disp_opts->{$try}
Aresult
11
00
158 ); };
159 0 ▶ last attempt if $gpw;
Branch: 1 branch
BranchTrueFalseTotal
if $gpw 0 0 0
160 }
161 }
162 0 ▶ die "Couldn't start a gnuplot interactive window" unless($gpw);
Branch: 1 branch
BranchTrueFalseTotal
unless $gpw 0 0 0
163 0 $mod->{itype} = $gpw->{terminal};
164 }
165 } else {
166 # File output - parse out file type, and then see if we support it.
167 # (Maybe the parsing part could be pushed into a utility routine...)
168  
169 # Filename extension -- 2-4 characters
170 0 my $ext;
171 0 ▶ if ($opt->{output} =~ m/\.(\w{2,4})$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'output'} =~ /\.(\w{2,4})$/) { } 0 0 0
172 0 $ext = $1;
173 } else {
174 0 $ext = '.png';
175 0 print STDERR "PDL::Graphics::Simple::Gnuplot: Warning - defaulting to .png type for file '$opt->{output}'\n";
176 }
177 0 $opt->{ext} = $ext;
178  
179 ##########
180 # Scan through the supported file types. Gnuplot has several drivers for some
181 # of the types, so we search until we find a valid one.
182 # At the end, $ft has either a valid terminal name from the table (at top),
183 # or undef.
184 0 my $ft = $filetypes->{$ext};
185 0 ▶ if (ref $ft eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ft eq 'ARRAY') { } 0 0 0
elsif (not defined $PDL::Graphics::Simple::Gnuplot::mod->{'valid_terms'}{$ft}) { } 0 0 0
186 0 try:for my $try (@$ft) {
187 0 ▶ if ($mod->{valid_terms}{$try}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{$try}) 0 0 0
188 0 $ft = $try;
189 0 last try;
190 }
191 }
192 0 ▶ if (ref($ft)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ft) 0 0 0
193 0 $ft = undef;
194 }
195 } elsif (!defined($mod->{valid_terms}{$ft})) {
196 0 $ft = undef;
197 }
198  
199 # Now $ext has the file type - check if its a supported type. If not, make a
200 # tempfilename to hold gnuplot's output.
201 0 ▶ unless ( defined($ft) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ft) 0 0 0
202 0 ▶ unless ($mod->{valid_terms}{pscairo} or $mod->{valid_terms}{postscript}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"pscairo"} or $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"postscript"}) 0 0 0
Condition0%0/3
$PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"pscairo"} or $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"postscript"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"pscairo"} or $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"postscript"}
$PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"pscairo"} $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"postscript"}
Truth table0%0/3
A or B
A= $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"pscairo"}B= $PDL::Graphics::Simple::Gnuplot::mod->{"valid_terms"}{"postscript"}
ABresult
1X1
011
000
203 0 die "PDL::Graphics::Simple: $ext isn't a valid output file type for your gnuplot,\n\tand it doesn't support .ps either. Sorry, I give up.\n";
204 }
205  
206 # Term is invalid but png is supported - set up a tempfile for conversion.
207 0 my($fh);
208 0 ($fh,$conv_tempfile) = tempfile('pgs_gnuplot_XXXX');
209 0 close $fh;
210 0 unlink($conv_tempfile); # just to be sure;
211 0 $conv_tempfile .= ".ps";
212 0 ▶ $ft = $mod->{valid_terms}{pscairo} ? 'pscairo' : 'postscript';
Branch: 1 branch
BranchTrueFalseTotal
$PDL::Graphics::Simple::Gnuplot::mod->{'valid_terms'}{'pscairo'} ? : 0 0 0
213 }
214 0 ▶ push @params, output => ($conv_tempfile || $opt->{output});
Condition0%0/3
$conv_tempfile || $opt->{'output'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$conv_tempfile || $opt->{'output'}
$conv_tempfile $opt->{'output'}
Truth table0%0/3
A || B
A= $conv_tempfileB= $opt->{'output'}
ABresult
1X1
011
000
215 0 ▶ push @params, color => 1 if $PDL::Graphics::Gnuplot::termTab->{$ft}{color};
Branch: 1 branch
BranchTrueFalseTotal
if $PDL::Graphics::Gnuplot::termTab->{$ft}{"color"} 0 0 0
216 0 ▶ push @params, dashed => 1 if $PDL::Graphics::Gnuplot::termTab->{$ft}{dashed};
Branch: 1 branch
BranchTrueFalseTotal
if $PDL::Graphics::Gnuplot::termTab->{$ft}{"dashed"} 0 0 0
217 0 $gpw = gpwin( $ft, @params );
218 }
219  
220  
221 0 my $me = { opt => $opt, conv_fn => $conv_tempfile, obj=>$gpw };
222  
223 # Deal with multiplot setup...
224 0 ▶ if (defined($opt->{multi})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt->{'multi'}) { } 0 0 0
225 0 $me->{nplots} = $opt->{multi}[0] * $opt->{multi}[1];
226 0 $me->{plot_no} = 0;
227 } else {
228 0 $me->{nplots} = 0;
229 }
230  
231 0 return bless($me, 'PDL::Graphics::Simple::Gnuplot');
232 }
233  
234  
235 ##############################
236 # PDL::Graphics::Simple::Gnuplot::plot
237 # Most of the curve types are implemented by passing them on to gnuplot -- circles is an
238 # exception, since the gnuplot "circles" curve type doesn't scale the circles in scientific
239 # coordinates (they are always rendered as circular on the screen), and we want to match
240 # the scaling behavior of the other engines.
241  
242 our $curve_types = {
243 points => 'points',
244 lines => 'lines',
245 bins => 'histeps',
246 errorbars => 'yerrorbars',
247 limitbars => 'yerrorbars',
248 image => 'image',
249 0 ▶ circles => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
250 0 my($me, $po, $co, @data) = @_;
251 0 my $ang = PDL->xvals(362)*3.14159/180;
252 0 my $c = $ang->cos;
253 0 my $s = $ang->sin;
254 0 $s->slice("361") .= $c->slice("361") .= PDL->pdl(1.1)->acos; # NaN
255 0 my $dr = $data[2]->flat;
256 0 my $dx = ($data[0]->flat->slice("*1") + $dr->slice("*1") * $c)->flat;
257 0 my $dy = ($data[1]->flat->slice("*1") + $dr->slice("*1") * $s)->flat;
258 0 $co->{with} = "lines";
259 0 return [ $co, $dx, $dy ];
260 },
261 0 ▶ contours => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
262 0 my ($me, $po, $co, $vals, $cvals) = @_;
263 0 $co->{with} = "lines";
264 0 ▶ $co->{style} //= 6; # so all contour parts have same style, blue somewhat visible against sepia
Condition0%0/2
$co->{"style"} //= 6
l!l
00
MC/DC0%0/1
$co->{"style"} //= 6
$co->{"style"}
Truth table0%0/2
A
A= $co->{"style"}
Aresult
11
00
265 0 my @out;
266 0 for my $thresh ($cvals->list) {
267 0 my ($pi, $p) = contour_polylines($thresh, $vals, $vals->ndcoords);
268 0 ▶ next if $pi->at(0) < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pi->at(0) < 0 0 0 0
269 0 push @out, map [ $co, $_->dog ], path_segs($pi, $p->mv(0,-1));
270 }
271 0 @out;
272 },
273 0 ▶ polylines => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
274 0 my ($me, $po, $co, $xy, $pen) = @_;
275 0 $co->{with} = "lines";
276 0 ▶ $co->{style} //= 6; # so all polylines have same style, blue somewhat visible against sepia
Condition0%0/2
$co->{"style"} //= 6
l!l
00
MC/DC0%0/1
$co->{"style"} //= 6
$co->{"style"}
Truth table0%0/2
A
A= $co->{"style"}
Aresult
11
00
277 0 my $pi = $pen->eq(0)->which;
278 0 map [ $co, $_->dog ], path_segs($pi, $xy->mv(0,-1));
279 },
280 fits => 'fits',
281 0 ▶ labels => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
282 0 my($me, $po, $co, @data) = @_;
283 0 ▶ my $label_list = ($po->{label} or []);
Condition0%0/2
$po->{'label'} || []
l!l
00
MC/DC0%0/1
$po->{'label'} || []
$po->{'label'}
Truth table0%0/2
A
A= $po->{'label'}
Aresult
11
00
284 0 for my $i(0..$data[0]->dim(0)-1) {
285 0 my $j = "";
286 0 my $s = $data[2]->[$i];
287 0 ▶ if ( $s =~ s/^([\<\>\| ])// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ s/^([\<\>\| ])//) 0 0 0
288 0 $j = $1;
289 }
290 0 my @spec = ("$s", at=>[$data[0]->at($i), $data[1]->at($i)]);
291 0 ▶ push @spec,"left" if $j eq '<';
Branch: 1 branch
BranchTrueFalseTotal
if $j eq "<" 0 0 0
292 0 ▶ push @spec,"center" if $j eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $j eq "|" 0 0 0
293 0 ▶ push @spec,"right" if $j eq '>';
Branch: 1 branch
BranchTrueFalseTotal
if $j eq ">" 0 0 0
294 0 push @{$label_list}, \@spec;
295 }
296 0 $po->{label} = $label_list;
297 0 $co->{with} = "labels";
298 0 return [ $co, [$po->{xrange}[0]], [$po->{yrange}[0]], [""] ];
299 },
300 1 };
301  
302 0 ▶sub plot {
Subroutine plot: not called CC=28 SCAR=67.0
Pod undocumented
303 0 my $me = shift;
304 0 my $ipo = shift;
305  
306 my $po = {
307 title => $ipo->{title},
308 xlab => $ipo->{xlabel},
309 ylab => $ipo->{ylabel},
310 key => $ipo->{key},
311 xrange => $ipo->{xrange},
312 yrange => $ipo->{yrange},
313 cbrange => $ipo->{crange},
314 colorbox => $ipo->{wedge},
315 justify => $ipo->{justify}>0 ? $ipo->{justify} : undef,
316 0 ▶ clut => 'sepia',
Branch: 1 branch
BranchTrueFalseTotal
$ipo->{'justify'} > 0 ? : 0 0 0
317 };
318  
319 0 ▶ if ( defined($ipo->{legend}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ipo->{"legend"}) 0 0 0
320 0 my $legend = "";
321 0 ▶ if ( $ipo->{legend} =~ m/l/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ipo->{'legend'} =~ /l/i) { } 0 0 0
elsif ($ipo->{'legend'} =~ /r/i) { } 0 0 0
322 0 $legend .= ' left ';
323 } elsif ($ipo->{legend} =~ m/r/i) {
324 0 $legend .= ' right ';
325 } else {
326 0 $legend .= ' center ';
327 }
328 0 ▶ if ( $ipo->{legend} =~ m/t/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ipo->{'legend'} =~ /t/i) { } 0 0 0
elsif ($ipo->{'legend'} =~ /b/i) { } 0 0 0
329 0 $legend .= ' top ';
330 } elsif ( $ipo->{legend} =~ m/b/i) {
331 0 $legend .= ' bottom ';
332 } else {
333 0 $legend .= ' center ';
334 }
335 0 $po->{key} = $legend;
336 }
337  
338 0 ▶ $po->{logscale} = [$ipo->{logaxis}] if $ipo->{logaxis};
Branch: 1 branch
BranchTrueFalseTotal
if $ipo->{"logaxis"} 0 0 0
339  
340 0 ▶ unless ($ipo->{oplot}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ipo->{"oplot"}) 0 0 0
341 0 $me->{curvestyle} = 0;
342 }
343  
344 0 my @arglist = $po;
345 0 for my $block (@_) {
346 die "PDL::Graphics::Simple::Gnuplot: undefined curve type $block->[0]{with}"
347 0 ▶ unless my $ct = $curve_types->{ $block->[0]{with} };
Branch: 1 branch
BranchTrueFalseTotal
unless my $ct = $$PDL::Graphics::Simple::Gnuplot::curve_types{$block->[0]{"with"}} 0 0 0
348 0 ▶ my @blocks = ref($ct) eq 'CODE' ? $ct->($me, $po, @$block) : [{%{$block->[0]}, with=>$ct}, @$block[1..$#$block]];
Branch: 1 branch
BranchTrueFalseTotal
ref $ct eq 'CODE' ? : 0 0 0
349 # Now parse out curve options and deal with line styles...
350 0 for my $b (@blocks) {
351 0 my ($co, @rest) = @$b;
352 0 my $gco = { with => $co->{with} };
353 0 ▶ unless($co->{with} eq 'labels') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($co->{"with"} eq "labels") 0 0 0
354 0 ▶ $me->{curvestyle} = $co->{style} // ($me->{curvestyle}//0)+1;
Condition0%0/4
$co->{"style"} // ($me->{"curvestyle"} // 0) + 1
l!l
00
$me->{"curvestyle"} // 0
l!l
00
MC/DC0%0/1
$co->{"style"} // ($me->{"curvestyle"} // 0) + 1
$co->{"style"}
Truth table0%0/2
A
A= $co->{"style"}
Aresult
11
00
355 0 $gco->{dashtype} = $gco->{linetype} = $me->{curvestyle};
356 0 ▶ if ( $co->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($co->{"width"}) 0 0 0
357 0 ▶ $gco->{pointsize} = $co->{width} if $co->{with} =~ m/^points/;
Branch: 1 branch
BranchTrueFalseTotal
if $co->{"with"} =~ /^points/ 0 0 0
358 0 $gco->{linewidth} = $co->{width};
359 }
360 }
361 0 ▶ $gco->{legend} = $co->{key} if defined $co->{key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $co->{"key"} 0 0 0
362 0 push @arglist, $gco, @rest;
363 }
364 }
365  
366 0 ▶ if ($me->{nplots}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"nplots"}) 0 0 0
367 0 ▶ unless($me->{plot_no}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($me->{"plot_no"}) 0 0 0
368 0 $me->{obj}->multiplot( layout=>[@{$me->{opt}{multi}}[0,1]] );
369 }
370 }
371  
372 0 ▶ if ($ipo->{oplot}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipo->{'oplot'}) { } 0 0 0
373 0 delete @$po{qw(logaxis xrange yrange cbrange justify)};
374 0 $me->{obj}->replot(@arglist);
375 } else {
376 0 $me->{obj}->plot(@arglist);
377 }
378  
379 0 ▶ if ($me->{nplots}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{'nplots'}) { } 0 0 0
380 0 $me->{plot_no}++;
381 0 ▶ if ($me->{plot_no} >= $me->{nplots}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"plot_no"} >= $me->{"nplots"}) 0 0 0
382 0 $me->{obj}->end_multi;
383 0 $me->{plot_no} = 0;
384 0 ▶ $me->{obj}->close if $me->{opt}{type} =~ m/^f/i;
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"opt"}{"type"} =~ /^f/i 0 0 0
385 }
386 } else {
387 0 ▶ $me->{obj}->close if $me->{opt}{type} =~ m/^f/i;
Branch: 1 branch
BranchTrueFalseTotal
if $me->{"opt"}{"type"} =~ /^f/i 0 0 0
388 }
389  
390 0 ▶ if ($me->{opt}{type} =~ m/^f/i and $me->{conv_fn}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->{"opt"}{"type"} =~ /^f/i and $me->{"conv_fn"}) 0 0 0
Condition0%0/3
$me->{"opt"}{"type"} =~ /^f/i and $me->{"conv_fn"}
!ll&&!rl&&r
000
MC/DC0%0/2
$me->{"opt"}{"type"} =~ /^f/i and $me->{"conv_fn"}
$me->{"opt"}{"type"} =~ /^f/i $me->{"conv_fn"}
Truth table0%0/3
A and B
A= $me->{"opt"}{"type"} =~ /^f/iB= $me->{"conv_fn"}
ABresult
0X0
100
111
391 0 print "converting $me->{conv_fn} to $me->{opt}{output}...";
392 0 $a = rim($me->{conv_fn});
393 0 wim($a->slice('-1:0:-1')->mv(1,0), $me->{opt}{output});
394 0 unlink($me->{conv_fn});
395 }
396 }
397  
398 1 1;
« Simple.pm ↑ Summary Simple/Prima.pm »