| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
#=============================================================================== |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# FILE: GnuplotIF.pm |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# DESCRIPTION: A simple and easy to use Perl interface to gnuplot. |
|
7
|
|
|
|
|
|
|
# (see POD below) |
|
8
|
|
|
|
|
|
|
# FILES: --- |
|
9
|
|
|
|
|
|
|
# BUGS: --- |
|
10
|
|
|
|
|
|
|
# NOTES: --- |
|
11
|
|
|
|
|
|
|
# AUTHOR: Dr.-Ing. Fritz Mehner (Mn), |
|
12
|
|
|
|
|
|
|
# COMPANY: FH Südwestfalen, Iserlohn |
|
13
|
|
|
|
|
|
|
# VERSION: see $VERSION below |
|
14
|
|
|
|
|
|
|
# CREATED: 16.07.2005 13:43:11 CEST |
|
15
|
|
|
|
|
|
|
# REVISION: $Id: GnuplotIF.pm,v 1.18 2011/06/03 17:34:08 mehner Exp $ |
|
16
|
|
|
|
|
|
|
#=============================================================================== |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Graphics::GnuplotIF; |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
76735
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
73
|
|
|
21
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
52
|
|
|
22
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
184
|
|
|
23
|
2
|
|
|
2
|
|
2086
|
use IO::Handle; |
|
|
2
|
|
|
|
|
16253
|
|
|
|
2
|
|
|
|
|
126
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '1.7'; # version number |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
15
|
use base qw(Exporter); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
221
|
|
|
28
|
2
|
|
|
2
|
|
10
|
use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
8281
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Symbols to be exported by default |
|
31
|
|
|
|
|
|
|
@EXPORT_OK = ( 'GnuplotIF' ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
34
|
|
|
|
|
|
|
# Code common to gnuplot_plot_xy and gnuplot_plot_y to allow user-specified |
|
35
|
|
|
|
|
|
|
# titles set by gnuplot_set_plot_titles. This code assumes the plot titles |
|
36
|
|
|
|
|
|
|
# were all set in the command to the literal text "", without any |
|
37
|
|
|
|
|
|
|
# surrounding quotes. This function replaces that text. |
|
38
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
39
|
|
|
|
|
|
|
my $private_apply_plot_titles = sub { |
|
40
|
|
|
|
|
|
|
my ($self, $cmd_ref) = @_; |
|
41
|
|
|
|
|
|
|
my $default_plot_title = q{-}; # Title if user did not specify one |
|
42
|
|
|
|
|
|
|
if (defined $self->{plot_titles} ) { |
|
43
|
|
|
|
|
|
|
# Substitute each plot title sequentially with the user-supplied value |
|
44
|
|
|
|
|
|
|
for my $plot_title (@{$self->{plot_titles}}) { |
|
45
|
|
|
|
|
|
|
if ( !defined $plot_title ) { |
|
46
|
|
|
|
|
|
|
$plot_title = $default_plot_title; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
${$cmd_ref} =~ s/title /title "$plot_title"/; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Substitute any plot titles we did not already catch globally |
|
53
|
|
|
|
|
|
|
${$cmd_ref} =~ s/title /title "$default_plot_title"/g; |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
57
|
|
|
|
|
|
|
# Code generates a file comment for a plot script. |
|
58
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
59
|
|
|
|
|
|
|
my $private_plot_script_header = sub { |
|
60
|
|
|
|
|
|
|
my ( $self ) = @_; |
|
61
|
|
|
|
|
|
|
my $localtime = scalar localtime; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $comment; |
|
64
|
|
|
|
|
|
|
($comment = <<"END") =~ s/^\s+//gm; |
|
65
|
|
|
|
|
|
|
# |
|
66
|
|
|
|
|
|
|
# This file is a GNUPLOT plot script. |
|
67
|
|
|
|
|
|
|
# It was generated automatically by '${0}' |
|
68
|
|
|
|
|
|
|
# using the Graphics::GnuplotIF extension to perl. |
|
69
|
|
|
|
|
|
|
# Creation time : ${localtime} |
|
70
|
|
|
|
|
|
|
# |
|
71
|
|
|
|
|
|
|
END |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$self->gnuplot_cmd( $comment ); |
|
74
|
|
|
|
|
|
|
return; |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
78
|
|
|
|
|
|
|
# warn if unix and there is no graphic display |
|
79
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
80
|
|
|
|
|
|
|
if (($^O ne 'MSWin32') and ($^O ne 'cygwin')) { |
|
81
|
|
|
|
|
|
|
if ( ! $ENV{'DISPLAY'} ) { |
|
82
|
|
|
|
|
|
|
warn "Graphics::GnuplotIF : cannot find environment variable DISPLAY \n" |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#=== FUNCTION ================================================================ |
|
87
|
|
|
|
|
|
|
# NAME: new |
|
88
|
|
|
|
|
|
|
# DESCRIPTION: constructor |
|
89
|
|
|
|
|
|
|
# PARAMETER 1: anonymous hash containing some plot parameter (defaults shown): |
|
90
|
|
|
|
|
|
|
# style => "lines" |
|
91
|
|
|
|
|
|
|
# title => "", |
|
92
|
|
|
|
|
|
|
# xlabel => "", |
|
93
|
|
|
|
|
|
|
# ylabel => "", |
|
94
|
|
|
|
|
|
|
# xrange => [], |
|
95
|
|
|
|
|
|
|
# yrange => [], |
|
96
|
|
|
|
|
|
|
# scriptfile => "", |
|
97
|
|
|
|
|
|
|
# persist => 0, |
|
98
|
|
|
|
|
|
|
# objectname => "", |
|
99
|
|
|
|
|
|
|
# RETURNS: object reference |
|
100
|
|
|
|
|
|
|
#=============================================================================== |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
|
|
|
|
|
|
my $object_number = 0; # number of objects created |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub new { |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
1
|
|
my ( $class, %args ) = @_; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $self = { |
|
109
|
|
|
|
|
|
|
program => 'gnuplot', # something like 'C:\gnuplot\binaries\gnuplot.exe' on Windows |
|
110
|
|
|
|
|
|
|
style => 'lines', |
|
111
|
|
|
|
|
|
|
title => q{}, |
|
112
|
|
|
|
|
|
|
xlabel => q{}, |
|
113
|
|
|
|
|
|
|
ylabel => q{}, |
|
114
|
|
|
|
|
|
|
xrange => [], |
|
115
|
|
|
|
|
|
|
yrange => [], |
|
116
|
|
|
|
|
|
|
plot_titles => [], |
|
117
|
|
|
|
|
|
|
scriptfile => q{}, |
|
118
|
|
|
|
|
|
|
persist => 0, |
|
119
|
|
|
|
|
|
|
objectname => q{}, |
|
120
|
|
|
|
|
|
|
silent_pause => 1, |
|
121
|
|
|
|
|
|
|
plot_also => 0, |
|
122
|
|
|
|
|
|
|
%args, |
|
123
|
|
|
|
|
|
|
__pausetime => -1, |
|
124
|
|
|
|
|
|
|
__pausemess => q{}, |
|
125
|
|
|
|
|
|
|
__objectnumber => ++$object_number, |
|
126
|
|
|
|
|
|
|
__plotnumber => 1, |
|
127
|
|
|
|
|
|
|
__error_log => q{}, |
|
128
|
|
|
|
|
|
|
__iohandle_pipe => undef, |
|
129
|
|
|
|
|
|
|
__iohandle_file => undef, |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
bless $self, $class ; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# let plot windows survive after gnuplot exits |
|
135
|
0
|
|
|
|
|
|
my $persist = q{}; |
|
136
|
0
|
0
|
|
|
|
|
if ( $self->{persist} == 1 ) { |
|
137
|
0
|
|
|
|
|
|
$persist = '-persist'; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
$self->{__error_log} = ".gnuplot.${$}.${object_number}.stderr.log"; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
143
|
|
|
|
|
|
|
# open pipe |
|
144
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
145
|
0
|
0
|
0
|
|
|
|
if ( $self->{scriptfile} eq q{} || ( $self->{scriptfile} ne q{} && $self->{plot_also} != 0 ) ) { |
|
|
|
|
0
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
open $self->{__iohandle_pipe}, '|- ', $self->{program}." ${persist} 2> $self->{__error_log}" |
|
147
|
|
|
|
|
|
|
or die "\n$0 : failed to open pipe to \"gnuplot\" : $!\n"; |
|
148
|
0
|
|
|
|
|
|
$self->{__iohandle_pipe}->autoflush(1); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
151
|
|
|
|
|
|
|
# open script file |
|
152
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
153
|
0
|
0
|
|
|
|
|
if ( $self->{scriptfile} ne q{} ) { |
|
154
|
0
|
0
|
|
|
|
|
open $self->{__iohandle_file}, '>', $self->{scriptfile} |
|
155
|
|
|
|
|
|
|
or die "\n$0 : failed to open file \"$self->{scriptfile}\" : $!\n"; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$self->$private_plot_script_header(); |
|
159
|
0
|
|
|
|
|
|
$self->gnuplot_set_style ( $self->{style } ); |
|
160
|
0
|
|
|
|
|
|
$self->gnuplot_set_title ( $self->{title } ); |
|
161
|
0
|
|
|
|
|
|
$self->gnuplot_set_xlabel( $self->{xlabel} ); |
|
162
|
0
|
|
|
|
|
|
$self->gnuplot_set_ylabel( $self->{ylabel} ); |
|
163
|
0
|
|
|
|
|
|
$self->gnuplot_set_xrange( @{$self->{xrange}} ); |
|
|
0
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
$self->gnuplot_set_yrange( @{$self->{yrange}} ); |
|
|
0
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return $self; |
|
167
|
|
|
|
|
|
|
} # ---------- end of subroutine new ---------- |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
171
|
|
|
|
|
|
|
# NAME: GnuplotIF |
|
172
|
|
|
|
|
|
|
# PURPOSE: constructor - short form |
|
173
|
|
|
|
|
|
|
# PARAMETERS: see new |
|
174
|
|
|
|
|
|
|
#=============================================================================== |
|
175
|
|
|
|
|
|
|
sub GnuplotIF { |
|
176
|
0
|
|
|
0
|
1
|
|
my @args = @_; |
|
177
|
0
|
|
|
|
|
|
return __PACKAGE__->new(@args); |
|
178
|
|
|
|
|
|
|
} # ---------- end of subroutine GnuplotIF ---------- |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
181
|
|
|
|
|
|
|
# NAME: DESTROY |
|
182
|
|
|
|
|
|
|
# PURPOSE: destructor - close pipe or file |
|
183
|
|
|
|
|
|
|
# PARAMETERS: --- |
|
184
|
|
|
|
|
|
|
#=============================================================================== |
|
185
|
|
|
|
|
|
|
sub DESTROY { |
|
186
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
187
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
188
|
|
|
|
|
|
|
# close pipe to gnuplot / close the script file |
|
189
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
190
|
0
|
0
|
0
|
|
|
|
if ( defined $self->{__iohandle_pipe} && !close $self->{__iohandle_pipe} ) { |
|
191
|
0
|
|
|
|
|
|
print { *STDERR } "Graphics::GnuplotIF (object $self->{__objectnumber}): " |
|
|
0
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
."problem closing communication to gnuplot\n"; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
0
|
0
|
0
|
|
|
|
if ( defined $self->{__iohandle_file} && !close $self->{__iohandle_file} ) { |
|
195
|
0
|
|
|
|
|
|
print { *STDERR } "Graphics::GnuplotIF (object $self->{__objectnumber}): " |
|
|
0
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
."problem closing file $self->{scriptfile}\n"; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
199
|
|
|
|
|
|
|
# remove empty error logfiles, if any |
|
200
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
201
|
0
|
|
|
|
|
|
my @stat = stat $self->{__error_log}; |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
0
|
0
|
|
|
|
if ( defined $stat[7] && $stat[7]==0 ) { |
|
204
|
0
|
0
|
|
|
|
|
unlink $self->{__error_log} |
|
205
|
|
|
|
|
|
|
or croak "Couldn't unlink $self->{__error_log}: $!" |
|
206
|
|
|
|
|
|
|
} |
|
207
|
0
|
|
|
|
|
|
return; |
|
208
|
|
|
|
|
|
|
} # ---------- end of subroutine DESTROY ---------- |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
211
|
|
|
|
|
|
|
# NAME: gnuplot_set_style |
|
212
|
|
|
|
|
|
|
# PURPOSE: Sets one of the allowed line styles in a plot command. |
|
213
|
|
|
|
|
|
|
# PARAMETERS: plotstyle (string) |
|
214
|
|
|
|
|
|
|
# RETURNS: --- |
|
215
|
|
|
|
|
|
|
# SEE ALSO: new() |
|
216
|
|
|
|
|
|
|
#=============================================================================== |
|
217
|
|
|
|
|
|
|
{ |
|
218
|
|
|
|
|
|
|
my %linestyles = # allowed line styles |
|
219
|
|
|
|
|
|
|
( |
|
220
|
|
|
|
|
|
|
boxes => q{}, |
|
221
|
|
|
|
|
|
|
dots => q{}, |
|
222
|
|
|
|
|
|
|
filledcurves=> q{}, |
|
223
|
|
|
|
|
|
|
fsteps => q{}, |
|
224
|
|
|
|
|
|
|
histeps => q{}, |
|
225
|
|
|
|
|
|
|
impulses => q{}, |
|
226
|
|
|
|
|
|
|
lines => q{}, |
|
227
|
|
|
|
|
|
|
linespoints => q{}, |
|
228
|
|
|
|
|
|
|
points => q{}, |
|
229
|
|
|
|
|
|
|
steps => q{}, |
|
230
|
|
|
|
|
|
|
); |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub gnuplot_set_style { |
|
233
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
234
|
0
|
|
|
|
|
|
my $style = shift; |
|
235
|
0
|
0
|
0
|
|
|
|
if ( defined $style && exists $linestyles{$style} ) { |
|
236
|
0
|
|
|
|
|
|
$self->{style} = $style; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
0
|
|
|
|
|
|
return; |
|
239
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_style ---------- |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
243
|
|
|
|
|
|
|
# NAME: gnuplot_plot_y |
|
244
|
|
|
|
|
|
|
# PURPOSE: Plot one or more arrays over 0, 1, 2, 3, ... |
|
245
|
|
|
|
|
|
|
# PARAMETERS: array reference(s) |
|
246
|
|
|
|
|
|
|
# RETURNS: --- |
|
247
|
|
|
|
|
|
|
#=============================================================================== |
|
248
|
|
|
|
|
|
|
sub gnuplot_plot_y { |
|
249
|
0
|
|
|
0
|
1
|
|
my ( $self, @yref ) = @_; |
|
250
|
0
|
|
|
|
|
|
my $parnr = 0; |
|
251
|
0
|
|
|
|
|
|
my $cmd = " '-' with $self->{style} title ,\\\n" x (scalar @yref); |
|
252
|
0
|
|
|
|
|
|
$cmd =~ s/,\\$//s; |
|
253
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles(\$cmd); # Honor gnuplot_set_plot_titles |
|
254
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
255
|
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "plot \\\n$cmd\n" ); |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
foreach my $item ( @yref ) { |
|
259
|
0
|
|
|
|
|
|
$parnr++; |
|
260
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_y : $parnr. " |
|
261
|
|
|
|
|
|
|
."argument not an array reference\n" |
|
262
|
|
|
|
|
|
|
if ref($item) ne 'ARRAY'; |
|
263
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( join( "\n", @{$item}), 'e' ); |
|
|
0
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
} # ----- end foreach ----- |
|
265
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
266
|
0
|
|
|
|
|
|
return $self; |
|
267
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_y ---------- |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
270
|
|
|
|
|
|
|
# NAME: gnuplot_plot_xy |
|
271
|
|
|
|
|
|
|
# PURPOSE: x-y-plot(s) |
|
272
|
|
|
|
|
|
|
# PARAMETERS: 1. array reference : x-values |
|
273
|
|
|
|
|
|
|
# 2. array reference : y-values |
|
274
|
|
|
|
|
|
|
# ... |
|
275
|
|
|
|
|
|
|
# RETURNS: --- |
|
276
|
|
|
|
|
|
|
# DESCRIPTION: Takes two or more array references. The first array is assumed |
|
277
|
|
|
|
|
|
|
# to contain the x-values for the following function values. |
|
278
|
|
|
|
|
|
|
#=============================================================================== |
|
279
|
|
|
|
|
|
|
sub gnuplot_plot_xy { |
|
280
|
0
|
|
|
0
|
1
|
|
my ( $self, $xref, @yref ) = @_; |
|
281
|
0
|
|
|
|
|
|
my $parnr = 1; |
|
282
|
0
|
|
|
|
|
|
my $cmd = " '-' using 1:2 with $self->{style} title ,\\\n" x (scalar @yref); |
|
283
|
0
|
|
|
|
|
|
$cmd =~ s/,\\\n$//s; |
|
284
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles(\$cmd); # Honor gnuplot_set_plot_titles |
|
285
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
286
|
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "plot \\\n$cmd\n" ); |
|
288
|
|
|
|
|
|
|
|
|
289
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_xy : $parnr. " |
|
290
|
|
|
|
|
|
|
."argument not an array reference\n" |
|
291
|
|
|
|
|
|
|
if ref($xref) ne 'ARRAY'; |
|
292
|
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
foreach my $j ( 0..$#yref ) { |
|
294
|
0
|
|
|
|
|
|
$parnr++; |
|
295
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_xy - " |
|
296
|
|
|
|
|
|
|
."$parnr. argument not an array reference\n" |
|
297
|
|
|
|
|
|
|
if ref($yref[$j]) ne 'ARRAY'; |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# there may be lesser y-values than x-values |
|
300
|
|
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
|
my $min = $#{$xref} < $#{$yref[$j]} ? $#{$xref} : $#{$yref[$j]}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
foreach my $i ( 0..$min ) { |
|
303
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "$$xref[$i] $yref[$j]->[$i]" ); |
|
304
|
|
|
|
|
|
|
} |
|
305
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'e' ); |
|
306
|
|
|
|
|
|
|
} |
|
307
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
308
|
0
|
|
|
|
|
|
return $self; |
|
309
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_xy ---------- |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
312
|
|
|
|
|
|
|
# NAME: gnuplot_plot_many |
|
313
|
|
|
|
|
|
|
# PURPOSE: x-y-plot(s) not sharing an x-axis |
|
314
|
|
|
|
|
|
|
# PARAMETERS: 1. array reference1 : x-values |
|
315
|
|
|
|
|
|
|
# 2. array reference1 : y-values |
|
316
|
|
|
|
|
|
|
# (3. array reference2 : x-values) |
|
317
|
|
|
|
|
|
|
# (4. array reference2 : y-values) |
|
318
|
|
|
|
|
|
|
# ... |
|
319
|
|
|
|
|
|
|
# RETURNS: --- |
|
320
|
|
|
|
|
|
|
# DESCRIPTION: Takes pairs of array references. The first array in each pair |
|
321
|
|
|
|
|
|
|
# is assumed to contain the x-values and the second pair is |
|
322
|
|
|
|
|
|
|
# assumed to contain y-values |
|
323
|
|
|
|
|
|
|
#=============================================================================== |
|
324
|
|
|
|
|
|
|
sub gnuplot_plot_many { |
|
325
|
0
|
|
|
0
|
1
|
|
my ( $self, @array_refs ) = @_; |
|
326
|
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
my $parnr = 0; |
|
328
|
0
|
|
|
|
|
|
my $cmd = " '-' using 1:2 with $self->{style} title ,\\\n" x |
|
329
|
|
|
|
|
|
|
( ( scalar @array_refs ) / 2 ); |
|
330
|
0
|
|
|
|
|
|
$cmd =~ s/,\\\n$//s; |
|
331
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles( \$cmd ); # Honor gnuplot_set_plot_titles |
|
332
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
333
|
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
$self->gnuplot_cmd("plot \\\n$cmd\n"); |
|
335
|
|
|
|
|
|
|
|
|
336
|
0
|
|
|
|
|
|
while (@array_refs) { |
|
337
|
0
|
|
|
|
|
|
my $xxr = shift @array_refs; |
|
338
|
0
|
|
|
|
|
|
$parnr++; |
|
339
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_many - " |
|
340
|
|
|
|
|
|
|
. "$parnr. argument not an array reference\n" |
|
341
|
|
|
|
|
|
|
if ref($xxr) ne 'ARRAY'; |
|
342
|
0
|
|
|
|
|
|
my $yyr = shift @array_refs; |
|
343
|
0
|
|
|
|
|
|
$parnr++; |
|
344
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_many - " |
|
345
|
|
|
|
|
|
|
. "$parnr. argument not an array reference\n" |
|
346
|
|
|
|
|
|
|
if ref($yyr) ne 'ARRAY'; |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# there may be fewer y-values than x-values |
|
349
|
|
|
|
|
|
|
|
|
350
|
0
|
0
|
|
|
|
|
my $min = $#{$xxr} < $#{$yyr} ? $#{$xxr} : $#{$yyr}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
351
|
0
|
|
|
|
|
|
foreach my $i ( 0 .. $min ) { |
|
352
|
0
|
|
|
|
|
|
$self->gnuplot_cmd("$$xxr[$i] $$yyr[$i]"); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
0
|
|
|
|
|
|
$self->gnuplot_cmd('e'); |
|
355
|
|
|
|
|
|
|
} |
|
356
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
357
|
0
|
|
|
|
|
|
return $self; |
|
358
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_many ---------- |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
361
|
|
|
|
|
|
|
# NAME: gnuplot_plot_xy_style |
|
362
|
|
|
|
|
|
|
# PURPOSE: x-y-plot(s) with each graph using individual settings |
|
363
|
|
|
|
|
|
|
# PARAMETERS: 1. array reference : x-values |
|
364
|
|
|
|
|
|
|
# 2. hash reference : (y-values, y-style) |
|
365
|
|
|
|
|
|
|
# ... |
|
366
|
|
|
|
|
|
|
# RETURNS: --- |
|
367
|
|
|
|
|
|
|
# DESCRIPTION: Takes one array reference and one or more hash references. |
|
368
|
|
|
|
|
|
|
# The first array is assumed to contain the x-values for the |
|
369
|
|
|
|
|
|
|
# following function values. The following hashes are assumed |
|
370
|
|
|
|
|
|
|
# to contain pairs of values and settings. |
|
371
|
|
|
|
|
|
|
#=============================================================================== |
|
372
|
|
|
|
|
|
|
sub gnuplot_plot_xy_style { |
|
373
|
0
|
|
|
0
|
1
|
|
my ( $self, $xref, @yref ) = @_; |
|
374
|
0
|
|
|
|
|
|
my $parnr = 1; |
|
375
|
0
|
|
|
|
|
|
my ( $cmd, @cmd ); |
|
376
|
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
foreach my $j ( 0..$#yref ) { |
|
378
|
0
|
0
|
0
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_xy_style - " |
|
|
|
|
0
|
|
|
|
|
|
379
|
|
|
|
|
|
|
.($parnr + $j + 1).". argument not a suitable hash reference\n" |
|
380
|
|
|
|
|
|
|
if ! (ref($yref[$j]) eq 'HASH' |
|
381
|
|
|
|
|
|
|
&& exists $yref[$j]->{'style_spec'} && exists $yref[$j]->{'y_values'}); |
|
382
|
|
|
|
|
|
|
|
|
383
|
0
|
|
|
|
|
|
push @cmd, " '-' using 1:2 with $yref[$j]->{'style_spec'} title "; |
|
384
|
|
|
|
|
|
|
} |
|
385
|
0
|
|
|
|
|
|
$cmd = join ", \\\n", @cmd; |
|
386
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles(\$cmd); # Honor gnuplot_set_plot_titles |
|
387
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
388
|
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "plot \\\n$cmd" ); |
|
390
|
|
|
|
|
|
|
|
|
391
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_xy_style : $parnr. " |
|
392
|
|
|
|
|
|
|
."argument not an array reference\n" |
|
393
|
|
|
|
|
|
|
if ref($xref) ne 'ARRAY'; |
|
394
|
|
|
|
|
|
|
|
|
395
|
0
|
|
|
|
|
|
foreach my $j ( 0..$#yref ) { |
|
396
|
0
|
|
|
|
|
|
$parnr++; |
|
397
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_xy_style - " |
|
398
|
|
|
|
|
|
|
."$parnr. argument is missing an array reference\n" |
|
399
|
|
|
|
|
|
|
if ref($yref[$j]->{'y_values'}) ne 'ARRAY'; |
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# there may be lesser y-values than x-values |
|
402
|
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
my $min = $#{$xref} < $#{$yref[$j]->{'y_values'}} |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
? $#{$xref} |
|
405
|
0
|
0
|
|
|
|
|
: $#{$yref[$j]->{'y_values'}}; |
|
406
|
0
|
|
|
|
|
|
foreach my $i ( 0..$min ) { |
|
407
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "$$xref[$i] $yref[$j]->{'y_values'}->[$i]" ); |
|
408
|
|
|
|
|
|
|
} |
|
409
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'e' ); |
|
410
|
|
|
|
|
|
|
} |
|
411
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
412
|
0
|
|
|
|
|
|
return $self; |
|
413
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_xy_style ---------- |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
416
|
|
|
|
|
|
|
# NAME: gnuplot_plot_many_style |
|
417
|
|
|
|
|
|
|
# PURPOSE: x-y-plot(s) not sharing an x-axis using individual settings |
|
418
|
|
|
|
|
|
|
# PARAMETERS: 1. hash reference1 : (x-values, y-values, y-style) |
|
419
|
|
|
|
|
|
|
# 2. hash reference2 : (x-values, y-values, y-style) |
|
420
|
|
|
|
|
|
|
# ... |
|
421
|
|
|
|
|
|
|
# RETURNS: --- |
|
422
|
|
|
|
|
|
|
# DESCRIPTION: Takes array of hash references. The hashes are assumed |
|
423
|
|
|
|
|
|
|
# to contain x- and y-values and settings. |
|
424
|
|
|
|
|
|
|
#=============================================================================== |
|
425
|
|
|
|
|
|
|
sub gnuplot_plot_many_style { |
|
426
|
0
|
|
|
0
|
1
|
|
my ( $self, @hash_refs ) = @_; |
|
427
|
0
|
|
|
|
|
|
my $parnr = 0; |
|
428
|
0
|
|
|
|
|
|
my ( $cmd, @cmd ); |
|
429
|
|
|
|
|
|
|
|
|
430
|
0
|
|
|
|
|
|
foreach my $rh (@hash_refs) { |
|
431
|
0
|
|
|
|
|
|
$parnr++; |
|
432
|
0
|
0
|
0
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_many_style - " |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
433
|
|
|
|
|
|
|
.($parnr).". argument not a suitable hash reference\n" |
|
434
|
|
|
|
|
|
|
if ! ( ref($rh) eq 'HASH' |
|
435
|
|
|
|
|
|
|
&& exists $rh->{'style_spec'} |
|
436
|
|
|
|
|
|
|
&& exists $rh->{'x_values'} |
|
437
|
|
|
|
|
|
|
&& exists $rh->{'y_values'} |
|
438
|
|
|
|
|
|
|
); |
|
439
|
0
|
|
|
|
|
|
my $style = $rh->{'style_spec'}; |
|
440
|
0
|
|
|
|
|
|
push @cmd, " '-' using 1:2 with $style title "; |
|
441
|
|
|
|
|
|
|
}; |
|
442
|
0
|
|
|
|
|
|
$cmd = join ", \\\n", @cmd; |
|
443
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles(\$cmd); # Honor gnuplot_set_plot_titles |
|
444
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
445
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "plot \\\n$cmd\n" ); |
|
446
|
|
|
|
|
|
|
|
|
447
|
0
|
|
|
|
|
|
$parnr = 0; |
|
448
|
0
|
|
|
|
|
|
foreach my $rh (@hash_refs) { |
|
449
|
0
|
|
|
|
|
|
my $xref = $rh->{'x_values'}; |
|
450
|
0
|
|
|
|
|
|
my $yref = $rh->{'y_values'}; |
|
451
|
0
|
|
|
|
|
|
$parnr++; |
|
452
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_many_style - " |
|
453
|
|
|
|
|
|
|
."$parnr. 'x_values' argument not an array reference\n" |
|
454
|
|
|
|
|
|
|
if ref($xref) ne 'ARRAY'; |
|
455
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_many_style - " |
|
456
|
|
|
|
|
|
|
."$parnr. 'y_values' argument not an array reference\n" |
|
457
|
|
|
|
|
|
|
if ref($yref) ne 'ARRAY'; |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
# there may be fewer y-values than x-values |
|
460
|
0
|
0
|
|
|
|
|
my $min = $#{$xref} < $#{$yref} ? $#{$xref} : $#{$yref}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
461
|
0
|
|
|
|
|
|
foreach my $i ( 0..$min ) { |
|
462
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "$$xref[$i] $$yref[$i]" ); |
|
463
|
|
|
|
|
|
|
} |
|
464
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'e' ); |
|
465
|
|
|
|
|
|
|
} |
|
466
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
467
|
0
|
|
|
|
|
|
return $self; |
|
468
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_many_style ---------- |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
471
|
|
|
|
|
|
|
# NAME: gnuplot_plot_equation |
|
472
|
|
|
|
|
|
|
# PURPOSE: Plot one or more functions described by strings. |
|
473
|
|
|
|
|
|
|
# PARAMETERS: strings describing functions |
|
474
|
|
|
|
|
|
|
# RETURNS: --- |
|
475
|
|
|
|
|
|
|
#=============================================================================== |
|
476
|
|
|
|
|
|
|
sub gnuplot_plot_equation { |
|
477
|
0
|
|
|
0
|
1
|
|
my ( $self, @equations ) = @_; |
|
478
|
0
|
|
|
|
|
|
my $leftside; |
|
479
|
|
|
|
|
|
|
my @leftside; |
|
480
|
|
|
|
|
|
|
|
|
481
|
0
|
|
|
|
|
|
foreach my $equ ( @equations ) { |
|
482
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "$equ" ); |
|
483
|
0
|
|
|
|
|
|
( $leftside ) = split /=/, $equ; |
|
484
|
0
|
|
|
|
|
|
push @leftside, $leftside; |
|
485
|
|
|
|
|
|
|
} # ----- end foreach ----- |
|
486
|
0
|
|
|
|
|
|
@leftside = map {$_." with $self->{style}"} @leftside; |
|
|
0
|
|
|
|
|
|
|
|
487
|
0
|
|
|
|
|
|
$leftside = join ', ', @leftside; |
|
488
|
0
|
0
|
|
|
|
|
return $self if $leftside eq q{}; |
|
489
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "plot $leftside" ); |
|
490
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
491
|
0
|
|
|
|
|
|
return $self; |
|
492
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_equation ---------- |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
495
|
|
|
|
|
|
|
# NAME: gnuplot_plot_3d |
|
496
|
|
|
|
|
|
|
# PURPOSE: Draw 3-d plots. |
|
497
|
|
|
|
|
|
|
# PARAMETERS: Reference to a 2-D-matrix containing the z-values. |
|
498
|
|
|
|
|
|
|
# RETURNS: --- |
|
499
|
|
|
|
|
|
|
#=============================================================================== |
|
500
|
|
|
|
|
|
|
sub gnuplot_plot_3d { |
|
501
|
0
|
|
|
0
|
1
|
|
my ( $self, $arrayref ) = @_; |
|
502
|
0
|
|
|
|
|
|
my $parnr = 0; |
|
503
|
0
|
|
|
|
|
|
my $cmd = " '-' matrix with $self->{style} title ," ; |
|
504
|
0
|
|
|
|
|
|
$cmd =~ s/,$//; |
|
505
|
0
|
|
|
|
|
|
$self->$private_apply_plot_titles(\$cmd); # Honor gnuplot_set_plot_titles |
|
506
|
0
|
0
|
|
|
|
|
return $self if $cmd eq q{}; |
|
507
|
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "splot $cmd" ); |
|
509
|
|
|
|
|
|
|
|
|
510
|
0
|
0
|
|
|
|
|
die "Graphics::GnuplotIF (object $self->{__objectnumber}): gnuplot_plot_3d : " |
|
511
|
|
|
|
|
|
|
."argument not an array reference\n" |
|
512
|
|
|
|
|
|
|
if ref($arrayref) ne 'ARRAY'; |
|
513
|
|
|
|
|
|
|
|
|
514
|
0
|
|
|
|
|
|
foreach my $i ( @{$arrayref} ) { |
|
|
0
|
|
|
|
|
|
|
|
515
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( join q{ }, @{$i} ) ; |
|
|
0
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
} |
|
517
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "\ne" ); |
|
518
|
|
|
|
|
|
|
|
|
519
|
0
|
|
|
|
|
|
$self->{__plotnumber}++; |
|
520
|
0
|
|
|
|
|
|
return $self; |
|
521
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_plot_3d ---------- |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
524
|
|
|
|
|
|
|
# NAME: gnuplot_pause |
|
525
|
|
|
|
|
|
|
# PURPOSE: Wait a specified amount of time. |
|
526
|
|
|
|
|
|
|
# PARAMETERS: 1. parameter (optional): time value (seconds): |
|
527
|
|
|
|
|
|
|
# -1 do not wait |
|
528
|
|
|
|
|
|
|
# 0 wait for a carriage return |
|
529
|
|
|
|
|
|
|
# >0 wait the specified number of seconds |
|
530
|
|
|
|
|
|
|
# 2. parameter (optional): text |
|
531
|
|
|
|
|
|
|
# message to display |
|
532
|
|
|
|
|
|
|
# RETURNS: --- |
|
533
|
|
|
|
|
|
|
#=============================================================================== |
|
534
|
|
|
|
|
|
|
sub gnuplot_pause { |
|
535
|
0
|
|
|
0
|
1
|
|
my ( $self, $pause, $message ) = @_; |
|
536
|
|
|
|
|
|
|
|
|
537
|
0
|
|
|
|
|
|
$self->{__pausetime} = 0; # default: wait for a carriage return |
|
538
|
0
|
0
|
0
|
|
|
|
if ( defined $pause && $pause =~ m/^[+-]?(\d+|\d+\.\d*|\d*\.\d+)$/x ) { |
|
539
|
0
|
|
|
|
|
|
$self->{__pausetime} = $pause; |
|
540
|
|
|
|
|
|
|
} |
|
541
|
0
|
0
|
0
|
|
|
|
if ( defined $message && $message ne q{} ) { |
|
542
|
0
|
|
|
|
|
|
$self->{__pausemess} = "\"$message\""; |
|
543
|
|
|
|
|
|
|
} |
|
544
|
0
|
|
|
|
|
|
my $msg0 = "Graphics::GnuplotIF (object $self->{__objectnumber}): $self->{__pausemess} -- "; |
|
545
|
0
|
|
|
|
|
|
my $msg1 = "hit RETURN to continue \n"; |
|
546
|
0
|
|
|
|
|
|
my $msg2 = "wait $self->{__pausetime} second(s) \n"; |
|
547
|
0
|
0
|
|
|
|
|
if ( $self->{__pausetime} == 0 ) { |
|
|
|
0
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
|
print "$msg0$msg1"; |
|
549
|
0
|
|
|
|
|
|
my $dummy = <>; # hit RETURN to go on |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
elsif ( $self->{__pausetime} < 0 ) { |
|
552
|
0
|
|
|
|
|
|
$self->gnuplot_cmd("\n"); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
else { |
|
555
|
0
|
0
|
|
|
|
|
if ( $self->{silent_pause} == 1 ) { |
|
556
|
0
|
|
|
|
|
|
print "$msg0$msg2"; |
|
557
|
|
|
|
|
|
|
} |
|
558
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "pause $self->{__pausetime}" ); |
|
559
|
|
|
|
|
|
|
} |
|
560
|
0
|
|
|
|
|
|
return $self; |
|
561
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_pause ---------- |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
564
|
|
|
|
|
|
|
# NAME: gnuplot_cmd |
|
565
|
|
|
|
|
|
|
# PURPOSE: Pass on one or more Gnuplot commands. |
|
566
|
|
|
|
|
|
|
# PARAMETERS: string(s) |
|
567
|
|
|
|
|
|
|
# RETURNS: --- |
|
568
|
|
|
|
|
|
|
#=============================================================================== |
|
569
|
|
|
|
|
|
|
sub gnuplot_cmd { |
|
570
|
0
|
|
|
0
|
1
|
|
my ($self, @commands) = @_; |
|
571
|
0
|
|
|
|
|
|
@commands = map {$_."\n"} @commands; |
|
|
0
|
|
|
|
|
|
|
|
572
|
0
|
0
|
|
|
|
|
if ( defined $self->{__iohandle_pipe} ) { |
|
573
|
0
|
0
|
|
|
|
|
print { $self->{__iohandle_pipe} } @commands |
|
|
0
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
or croak "Couldn't write to pipe: $!"; |
|
575
|
|
|
|
|
|
|
} |
|
576
|
0
|
0
|
|
|
|
|
if ( defined $self->{__iohandle_file} ) { |
|
577
|
0
|
0
|
|
|
|
|
print { $self->{__iohandle_file} } @commands |
|
|
0
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
or croak "Couldn't write to file $!"; |
|
579
|
|
|
|
|
|
|
} |
|
580
|
0
|
|
|
|
|
|
return $self; |
|
581
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_cmd ---------- |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
584
|
|
|
|
|
|
|
# NAME: gnuplot_hardcopy |
|
585
|
|
|
|
|
|
|
# PURPOSE: Write a plot into a file. |
|
586
|
|
|
|
|
|
|
# PARAMETERS: 1. file name |
|
587
|
|
|
|
|
|
|
# 2. gnuplot terminal type |
|
588
|
|
|
|
|
|
|
# 3. terminal settings (optional) |
|
589
|
|
|
|
|
|
|
# RETURNS: --- |
|
590
|
|
|
|
|
|
|
#=============================================================================== |
|
591
|
|
|
|
|
|
|
sub gnuplot_hardcopy { |
|
592
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $terminal, @keywords) = @_; |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
# remember the current terminal including its settings |
|
595
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'set terminal push' ); |
|
596
|
|
|
|
|
|
|
|
|
597
|
0
|
|
|
|
|
|
my $set_terminal = "set terminal $terminal @keywords\n"; |
|
598
|
0
|
|
|
|
|
|
my $set_output = "set output \"$filename\"\n"; |
|
599
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( $set_terminal, $set_output ); |
|
600
|
0
|
|
|
|
|
|
return $self; |
|
601
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_hardcopy ---------- |
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
604
|
|
|
|
|
|
|
# NAME: gnuplot_restore_terminal |
|
605
|
|
|
|
|
|
|
# PURPOSE: Restore the terminal settings before the last hardcopy. |
|
606
|
|
|
|
|
|
|
# PARAMETERS: --- |
|
607
|
|
|
|
|
|
|
# RETURNS: --- |
|
608
|
|
|
|
|
|
|
#=============================================================================== |
|
609
|
|
|
|
|
|
|
sub gnuplot_restore_terminal { |
|
610
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
611
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'set output', 'set terminal pop' ); |
|
612
|
0
|
|
|
|
|
|
return $self; |
|
613
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_restore_terminal ---------- |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
616
|
|
|
|
|
|
|
# NAME: gnuplot_set_plot_titles |
|
617
|
|
|
|
|
|
|
# PURPOSE: Sets the list of titles used in the key. |
|
618
|
|
|
|
|
|
|
# PARAMETERS: array of titles |
|
619
|
|
|
|
|
|
|
# RETURNS: --- |
|
620
|
|
|
|
|
|
|
#=============================================================================== |
|
621
|
|
|
|
|
|
|
sub gnuplot_set_plot_titles { |
|
622
|
0
|
|
|
0
|
1
|
|
my ( $self, @user_plot_titles ) = @_; |
|
623
|
0
|
|
|
|
|
|
my @plot_titles = @user_plot_titles; |
|
624
|
0
|
|
|
|
|
|
$self->{plot_titles} = \@plot_titles; |
|
625
|
0
|
|
|
|
|
|
return $self; |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
629
|
|
|
|
|
|
|
# NAME: gnuplot_reset |
|
630
|
|
|
|
|
|
|
# PURPOSE: Set all options set with the set command to their |
|
631
|
|
|
|
|
|
|
# gnuplot default values. |
|
632
|
|
|
|
|
|
|
# PARAMETERS: --- |
|
633
|
|
|
|
|
|
|
# RETURNS: --- |
|
634
|
|
|
|
|
|
|
#=============================================================================== |
|
635
|
|
|
|
|
|
|
sub gnuplot_reset { |
|
636
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
637
|
0
|
|
|
|
|
|
$self->{plot_titles} = undef; |
|
638
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( 'reset' ); |
|
639
|
0
|
|
|
|
|
|
return $self; |
|
640
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_reset ---------- |
|
641
|
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
643
|
|
|
|
|
|
|
# NAME: gnuplot_set_title |
|
644
|
|
|
|
|
|
|
# PURPOSE: Sets the plot title. |
|
645
|
|
|
|
|
|
|
# PARAMETERS: title (string) |
|
646
|
|
|
|
|
|
|
# RETURNS: --- |
|
647
|
|
|
|
|
|
|
#=============================================================================== |
|
648
|
|
|
|
|
|
|
sub gnuplot_set_title { |
|
649
|
0
|
|
|
0
|
1
|
|
my ( $self, $title ) = @_; |
|
650
|
0
|
0
|
|
|
|
|
if ( defined $title ) { |
|
651
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "set title '$title'" ); |
|
652
|
|
|
|
|
|
|
}; |
|
653
|
0
|
|
|
|
|
|
return $self; |
|
654
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_title ---------- |
|
655
|
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
657
|
|
|
|
|
|
|
# NAME: gnuplot_set_xlabel |
|
658
|
|
|
|
|
|
|
# PURPOSE: Sets the x axis label. |
|
659
|
|
|
|
|
|
|
# PARAMETERS: string |
|
660
|
|
|
|
|
|
|
# RETURNS: --- |
|
661
|
|
|
|
|
|
|
#=============================================================================== |
|
662
|
|
|
|
|
|
|
sub gnuplot_set_xlabel { |
|
663
|
0
|
|
|
0
|
1
|
|
my ( $self, $xlabel ) = @_; |
|
664
|
0
|
0
|
|
|
|
|
if ( defined $xlabel ) { |
|
665
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "set xlabel \"$xlabel\"" ); |
|
666
|
|
|
|
|
|
|
}; |
|
667
|
0
|
|
|
|
|
|
return $self; |
|
668
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_xlabel ---------- |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
671
|
|
|
|
|
|
|
# NAME: gnuplot_set_ylabel |
|
672
|
|
|
|
|
|
|
# PURPOSE: Sets the y axis label. |
|
673
|
|
|
|
|
|
|
# PARAMETERS: string |
|
674
|
|
|
|
|
|
|
# RETURNS: --- |
|
675
|
|
|
|
|
|
|
#=============================================================================== |
|
676
|
|
|
|
|
|
|
sub gnuplot_set_ylabel { |
|
677
|
0
|
|
|
0
|
1
|
|
my ( $self, $ylabel ) = @_; |
|
678
|
0
|
0
|
|
|
|
|
if ( defined $ylabel ) { |
|
679
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "set ylabel \"$ylabel\"" ); |
|
680
|
|
|
|
|
|
|
}; |
|
681
|
0
|
|
|
|
|
|
return $self; |
|
682
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_ylabel ---------- |
|
683
|
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
685
|
|
|
|
|
|
|
# NAME: gnuplot_set_xrange |
|
686
|
|
|
|
|
|
|
# PURPOSE: Sets the horizontal range that will be displayed. |
|
687
|
|
|
|
|
|
|
# PARAMETERS: 1. parameter: range, left value |
|
688
|
|
|
|
|
|
|
# 2. parameter: range, right value |
|
689
|
|
|
|
|
|
|
# RETURNS: --- |
|
690
|
|
|
|
|
|
|
#=============================================================================== |
|
691
|
|
|
|
|
|
|
sub gnuplot_set_xrange { |
|
692
|
0
|
|
|
0
|
1
|
|
my ( $self, $xleft, $xright ) = @_; |
|
693
|
0
|
0
|
0
|
|
|
|
if ( defined $xleft && defined $xright ) { |
|
694
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "set xrange [ $xleft : $xright ]" ); |
|
695
|
|
|
|
|
|
|
} |
|
696
|
0
|
|
|
|
|
|
return $self; |
|
697
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_xrange ---------- |
|
698
|
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
700
|
|
|
|
|
|
|
# NAME: gnuplot_set_yrange |
|
701
|
|
|
|
|
|
|
# PURPOSE: Sets the vertical range that will be displayed. |
|
702
|
|
|
|
|
|
|
# PARAMETERS: 1. parameter: range, low value |
|
703
|
|
|
|
|
|
|
# 2. parameter: range, high value |
|
704
|
|
|
|
|
|
|
# RETURNS: --- |
|
705
|
|
|
|
|
|
|
#=============================================================================== |
|
706
|
|
|
|
|
|
|
sub gnuplot_set_yrange { |
|
707
|
0
|
|
|
0
|
1
|
|
my ( $self, $yleft, $yright ) = @_; |
|
708
|
0
|
0
|
0
|
|
|
|
if ( defined $yleft && defined $yright ) { |
|
709
|
0
|
|
|
|
|
|
$self->gnuplot_cmd( "set yrange [ $yleft : $yright ]" ); |
|
710
|
|
|
|
|
|
|
} |
|
711
|
0
|
|
|
|
|
|
return $self; |
|
712
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_set_yrange ---------- |
|
713
|
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
715
|
|
|
|
|
|
|
# NAME: gnuplot_get_plotnumber |
|
716
|
|
|
|
|
|
|
# PURPOSE: Get the (internal) plot number |
|
717
|
|
|
|
|
|
|
# PARAMETERS: --- |
|
718
|
|
|
|
|
|
|
# RETURNS: object number |
|
719
|
|
|
|
|
|
|
#=============================================================================== |
|
720
|
|
|
|
|
|
|
sub gnuplot_get_plotnumber { |
|
721
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
722
|
0
|
|
|
|
|
|
return $self->{__plotnumber}; |
|
723
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_get_plotnumber ---------- |
|
724
|
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
|
726
|
|
|
|
|
|
|
# NAME: gnuplot_get_object_id |
|
727
|
|
|
|
|
|
|
# PURPOSE: Get the (internal) object number |
|
728
|
|
|
|
|
|
|
# PARAMETERS: --- |
|
729
|
|
|
|
|
|
|
# RETURNS: object number |
|
730
|
|
|
|
|
|
|
#=============================================================================== |
|
731
|
|
|
|
|
|
|
sub gnuplot_get_object_id { |
|
732
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
733
|
0
|
0
|
|
|
|
|
if ( wantarray ) { |
|
734
|
0
|
|
|
|
|
|
return ( $self->{__objectnumber}, $self->{objectname} ); |
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
else { |
|
737
|
0
|
|
|
|
|
|
return $self->{__objectnumber}; |
|
738
|
|
|
|
|
|
|
} |
|
739
|
|
|
|
|
|
|
} # ---------- end of subroutine gnuplot_get_object_id ---------- |
|
740
|
|
|
|
|
|
|
|
|
741
|
2
|
|
|
2
|
|
4382
|
END { } # module clean-up code |
|
742
|
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
1; |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
#__END__ |
|
746
|
|
|
|
|
|
|
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
747
|
|
|
|
|
|
|
# Module Documentation |
|
748
|
|
|
|
|
|
|
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
749
|
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head1 NAME |
|
751
|
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
Graphics::GnuplotIF - A dynamic Perl interface to gnuplot |
|
753
|
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=head1 VERSION |
|
755
|
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
This documentation refers to Graphics::GnuplotIF version 1.6 |
|
757
|
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
759
|
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
use Graphics::GnuplotIF qw(GnuplotIF); |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
my @x = ( -2, -1.50, -1, -0.50, 0, 0.50, 1, 1.50, 2 ); # x values |
|
763
|
|
|
|
|
|
|
my @y1 = ( 4, 2.25, 1, 0.25, 0, 0.25, 1, 2.25, 4 ); # function 1 |
|
764
|
|
|
|
|
|
|
my @y2 = ( 2, 0.25, -1, -1.75, -2, -1.75, -1, 0.25, 2 ); # function 2 |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
my $plot1 = Graphics::GnuplotIF->new(title => "line", style => "points"); |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
$plot1->gnuplot_plot_y( \@x ); # plot 9 points over 0..8 |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
$plot1->gnuplot_pause( ); # hit RETURN to continue |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
$plot1->gnuplot_set_title( "parabola" ); # new title |
|
773
|
|
|
|
|
|
|
$plot1->gnuplot_set_style( "lines" ); # new line style |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy( \@x, \@y1, \@y2 ); # plot 1: y1, y2 over x |
|
776
|
|
|
|
|
|
|
$plot1->gnuplot_plot_many( \@x, \@y1, \@x, \@y2 ); # plot 1: y1 - x, y2 - x |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
my $plot2 = Graphics::GnuplotIF->new; # new plot object |
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
$plot2->gnuplot_set_xrange( 0, 4 ); # set x range |
|
781
|
|
|
|
|
|
|
$plot2->gnuplot_set_yrange( -2, 2 ); # set y range |
|
782
|
|
|
|
|
|
|
$plot2->gnuplot_cmd( "set grid" ); # send a gnuplot command |
|
783
|
|
|
|
|
|
|
$plot2->gnuplot_plot_equation( # 3 equations in one plot |
|
784
|
|
|
|
|
|
|
"y1(x) = sin(x)", |
|
785
|
|
|
|
|
|
|
"y2(x) = cos(x)", |
|
786
|
|
|
|
|
|
|
"y3(x) = sin(x)/x" ); |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
$plot2->gnuplot_pause( ); # hit RETURN to continue |
|
789
|
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
$plot2->gnuplot_plot_equation( # rewrite plot 2 |
|
791
|
|
|
|
|
|
|
"y4(x) = 2*exp(-x)*sin(4*x)" ); |
|
792
|
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
$plot2->gnuplot_pause( ); # hit RETURN to continue |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
my $plot3 = GnuplotIF; # new plot object |
|
796
|
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
my @xyz = ( # 2-D-matrix, z-values |
|
798
|
|
|
|
|
|
|
[0, 1, 4, 9], |
|
799
|
|
|
|
|
|
|
[1, 2, 6, 15], |
|
800
|
|
|
|
|
|
|
[4, 6, 12, 27], |
|
801
|
|
|
|
|
|
|
[9, 15, 27, 54], |
|
802
|
|
|
|
|
|
|
); |
|
803
|
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
$plot3->gnuplot_cmd( "set grid" ); # send a gnuplot command |
|
805
|
|
|
|
|
|
|
$plot3->gnuplot_set_plot_titles("surface"); # set legend |
|
806
|
|
|
|
|
|
|
$plot3->gnuplot_plot_3d( \@xyz ); # start 3-D-plot |
|
807
|
|
|
|
|
|
|
$plot3->gnuplot_pause( ); # hit RETURN to continue |
|
808
|
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
810
|
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
Graphics::GnuplotIF is a simple and easy to use dynamic Perl interface to |
|
812
|
|
|
|
|
|
|
B. B is a freely available, command-driven graphical display |
|
813
|
|
|
|
|
|
|
tool for Unix. It compiles and works quite well on a number of Unix flavours |
|
814
|
|
|
|
|
|
|
as well as other operating systems, including Windows with C. |
|
815
|
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
This module enables sending display requests asynchronously to B |
|
817
|
|
|
|
|
|
|
through simple Perl subroutine calls. |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
A gnuplot session is an instance of class Graphics::GnuplotIF. The constructor |
|
820
|
|
|
|
|
|
|
starts B as a separate process for each session. The plot commands are |
|
821
|
|
|
|
|
|
|
send through a I. The graphical output from B will be displayed |
|
822
|
|
|
|
|
|
|
immediately. |
|
823
|
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
Several independent plots can be started from one script. Each plot has its |
|
825
|
|
|
|
|
|
|
own pipe. All pipes will be closed automatically by the destructor when the |
|
826
|
|
|
|
|
|
|
script terminates. The B processes terminate when the corresponding |
|
827
|
|
|
|
|
|
|
pipes are closed. Their graphical output will now disappear (but see parameter |
|
828
|
|
|
|
|
|
|
L). |
|
829
|
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
Graphics::GnuplotIF is similar to C< gnuplot_i >, a C interface to B |
|
831
|
|
|
|
|
|
|
( http://ndevilla.free.fr/gnuplot/ ), and to C< gnuplot_i++ >, a C++ interface |
|
832
|
|
|
|
|
|
|
to B ( http://jijo.cjb.net/code/cc++ ). |
|
833
|
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
An object of this class represents an interface to a running B |
|
837
|
|
|
|
|
|
|
process. During the creation of an object such an process will be started for |
|
838
|
|
|
|
|
|
|
each such object. Communication is done through an unidirectional pipe; the |
|
839
|
|
|
|
|
|
|
resulting stream is write-only. |
|
840
|
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
Most methods return a reference to the Graphics::GnuplotIF object, allowing |
|
842
|
|
|
|
|
|
|
method calls to be chained like so: |
|
843
|
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
$plot1 -> gnuplot_plot_xy(\@x, \@y) |
|
845
|
|
|
|
|
|
|
-> gnuplot_reset; |
|
846
|
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
The exception to this are L and |
|
848
|
|
|
|
|
|
|
L, which are used to obtain specific scalar |
|
849
|
|
|
|
|
|
|
values. |
|
850
|
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
=head2 new |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
The constructor creates a new B session object, referenced by a |
|
854
|
|
|
|
|
|
|
handle: |
|
855
|
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
$plot1 = Graphics::GnuplotIF->new( ); |
|
857
|
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
A few named arguments can be passed as key - value pairs (here shown with |
|
859
|
|
|
|
|
|
|
their default values): |
|
860
|
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
program => 'gnuplot' # fully qualified name of the Gnuplot executable |
|
862
|
|
|
|
|
|
|
style => 'lines', # one of the gnuplot line styles (see below) |
|
863
|
|
|
|
|
|
|
title => '', # string |
|
864
|
|
|
|
|
|
|
xlabel => 'x', # string |
|
865
|
|
|
|
|
|
|
ylabel => 'y', # string |
|
866
|
|
|
|
|
|
|
xrange => [], # array reference; autoscaling, if empty |
|
867
|
|
|
|
|
|
|
xrange => [], # array reference; autoscaling, if empty |
|
868
|
|
|
|
|
|
|
plot_titles => [], # array of strings; titles used in the legend |
|
869
|
|
|
|
|
|
|
scriptfile => '', # write all plot commands to the specified file |
|
870
|
|
|
|
|
|
|
plot_also => 0, # write all plot commands to the specified file, |
|
871
|
|
|
|
|
|
|
# in addition show the plots |
|
872
|
|
|
|
|
|
|
persist => 0, # let plot windows survive after gnuplot exits |
|
873
|
|
|
|
|
|
|
# 0 : close / 1 : survive |
|
874
|
|
|
|
|
|
|
objectname => '', # an optional name for the object |
|
875
|
|
|
|
|
|
|
silent_pause => 1, # 0 suppress message from gnuplot_pause() |
|
876
|
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
These attributes are stored in each object. |
|
878
|
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
Allowed line styles are |
|
880
|
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
boxes dots filledcurves fsteps histeps |
|
882
|
|
|
|
|
|
|
impulses lines linespoints points steps |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
The generated B commands can be stored to a file instead of beeing |
|
885
|
|
|
|
|
|
|
executed immediately. This file can be used as input to B, e.g. |
|
886
|
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
gnuplot < function_set_1.gnuplot |
|
888
|
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
A script file can also be used for checking the commands send to B. |
|
890
|
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
The objects are automatically deleted by a destructor. The destructor closes |
|
892
|
|
|
|
|
|
|
the pipe to the B process belonging to that object. The B |
|
893
|
|
|
|
|
|
|
process will also terminate and remove the graphic output. The termination can |
|
894
|
|
|
|
|
|
|
be controlled by the method L | gnuplot_pause> . |
|
895
|
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
The program argument is provided to allow Graphics::GnuplotIF to be |
|
897
|
|
|
|
|
|
|
used with Gnuplot on Windows using C, a compilation |
|
898
|
|
|
|
|
|
|
which includes code that emulates a unix pipe. |
|
899
|
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
=head2 GnuplotIF |
|
901
|
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
The short form of the constructor above (L|new>): |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
use Graphics::GnuplotIF qw(GnuplotIF); |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
$plot1 = GnuplotIF; |
|
907
|
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
This subroutine is exported only on request. |
|
909
|
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
=head2 gnuplot_plot_y |
|
911
|
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
$plot1->gnuplot_plot_y( \@y1, \@y2 ); |
|
913
|
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
C takes one or more array references and plots the values over |
|
915
|
|
|
|
|
|
|
the x-values 0, 1, 2, 3, ... |
|
916
|
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
=head2 gnuplot_plot_xy |
|
918
|
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy( \@x, \@y1, \@y2 ); |
|
920
|
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
C takes two or more array references. The first array is |
|
922
|
|
|
|
|
|
|
assumed to contain the x-values for the following function values. |
|
923
|
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
=head2 gnuplot_plot_xy_style |
|
925
|
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
%y1 = ( 'y_values' => \@y1, 'style_spec' => "lines lw 3" ); |
|
927
|
|
|
|
|
|
|
%y2 = ( 'y_values' => \@y2, |
|
928
|
|
|
|
|
|
|
'style_spec' => "points pointtype 4 pointsize 5" ); |
|
929
|
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy_style( \@x, \%y1, \%y2 ); |
|
931
|
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
C takes one array reference and one or more hash |
|
933
|
|
|
|
|
|
|
references. The first array is assumed to contain the x-values for the |
|
934
|
|
|
|
|
|
|
following function values. The following hashes are assumed to contain pairs of |
|
935
|
|
|
|
|
|
|
y-values and individual style specifications for use in the plot command. The |
|
936
|
|
|
|
|
|
|
'style_spec' settings are placed between C and C of B's |
|
937
|
|
|
|
|
|
|
C command. |
|
938
|
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
=head2 gnuplot_plot_many |
|
940
|
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy( \@x1, \@y1, \@x2, \@y2 ); |
|
942
|
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
C takes pairs of array references. Each pair represents a |
|
944
|
|
|
|
|
|
|
function and is a reference to the arrays of x- and y-values for that function. |
|
945
|
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
=head2 gnuplot_plot_many_style |
|
947
|
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
%f1 = ( 'x_values' => \@x1, 'y_values' => \@y1, |
|
949
|
|
|
|
|
|
|
'style_spec' => "lines lw 3" ); |
|
950
|
|
|
|
|
|
|
%f2 = ( 'x_values' => \@x2, 'y_values' => \@y2, |
|
951
|
|
|
|
|
|
|
'style_spec' => "points pointtype 4 pointsize 5" ); |
|
952
|
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
$plot1->gnuplot_plot_many_style( \%f1, \%f2 ); |
|
954
|
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
C takes one or more hash references. The hashes are |
|
956
|
|
|
|
|
|
|
assumed to contain array referenses to x-values and y-values and individual |
|
957
|
|
|
|
|
|
|
style specifications for use in the plot command. The 'style_spec' settings are |
|
958
|
|
|
|
|
|
|
placed between C and C of B's C command. |
|
959
|
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
=head2 gnuplot_plot_equation |
|
961
|
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
$plot2->gnuplot_plot_equation( # 3 equations in one plot |
|
963
|
|
|
|
|
|
|
"y1(x) = sin(x)", |
|
964
|
|
|
|
|
|
|
"y2(x) = cos(x)", |
|
965
|
|
|
|
|
|
|
"y3(x) = sin(x)/x" ); |
|
966
|
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
C takes one or more B function descriptions as |
|
968
|
|
|
|
|
|
|
strings. The plot ranges can be controlled by |
|
969
|
|
|
|
|
|
|
L|gnuplot_set_xrange> and |
|
970
|
|
|
|
|
|
|
L|gnuplot_set_yrange> . |
|
971
|
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
=head2 gnuplot_plot_3d |
|
973
|
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
$plot2->gnuplot_plot_3d( \@array ); # 3-D-plot |
|
975
|
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
C takes one reference to an 2-D-array of z-values. |
|
977
|
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
=head2 gnuplot_pause |
|
979
|
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
$plot1->gnuplot_pause( [time] [,text] ); |
|
981
|
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
This is an emulation of the B C command. It displays any text |
|
983
|
|
|
|
|
|
|
associated with the command and waits a specified amount of time or until the |
|
984
|
|
|
|
|
|
|
carriage return is pressed. The message can be suppressed by |
|
985
|
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
silent_pause => 0 |
|
987
|
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
given to the constructor (see L). |
|
989
|
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
C |
|
991
|
|
|
|
|
|
|
wait until a carriage return is hit, a negative value won't pause at |
|
992
|
|
|
|
|
|
|
all, and a positive number will wait the specified number of seconds. |
|
993
|
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
The time value and the text are stored in the object and reused. A sequence |
|
995
|
|
|
|
|
|
|
like |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
$plot1->gnuplot_plot_y( \@y1 ); |
|
998
|
|
|
|
|
|
|
$plot1->gnuplot_pause( 5.5 ); # delay is 5.5 seconds |
|
999
|
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
$plot1->gnuplot_plot_y( \@y2 ); |
|
1001
|
|
|
|
|
|
|
$plot1->gnuplot_pause( ); |
|
1002
|
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
$plot1->gnuplot_plot_y( \@y3 ); |
|
1004
|
|
|
|
|
|
|
$plot1->gnuplot_pause( ); |
|
1005
|
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
will display 3 plots with 5.5 seconds delay. |
|
1007
|
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
=head2 gnuplot_cmd |
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
$plot2->gnuplot_cmd( 'set grid', |
|
1012
|
|
|
|
|
|
|
'set timestamp "%d/%m/%y %H:%M" 0,0 "Helvetica"' |
|
1013
|
|
|
|
|
|
|
); |
|
1014
|
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
C can be used to send one or more B commands, especially |
|
1016
|
|
|
|
|
|
|
those not wrapped by a Graphics::GnuplotIF method. |
|
1017
|
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
=head2 gnuplot_reset |
|
1019
|
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
$plot1->gnuplot_reset(); |
|
1021
|
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
Set all options set with the C command to their B default values. |
|
1023
|
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
=head2 gnuplot_set_style |
|
1025
|
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
$plot1->gnuplot_set_style( "steps" ); # new line style |
|
1027
|
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
Sets one of the allowed line styles (see L) |
|
1029
|
|
|
|
|
|
|
in a plot command. |
|
1030
|
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
=head2 gnuplot_set_title |
|
1032
|
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
$plot1->gnuplot_set_title("parabola"); # new title |
|
1034
|
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
Sets the plot title. |
|
1036
|
|
|
|
|
|
|
Equivalent to the B command C. |
|
1037
|
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
=head2 gnuplot_set_xlabel |
|
1039
|
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
$plot1->gnuplot_set_xlabel("time (days)"); |
|
1041
|
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
Sets the x axis label. |
|
1043
|
|
|
|
|
|
|
Equivalent to the B command C. |
|
1044
|
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
=head2 gnuplot_set_ylabel |
|
1046
|
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
$plot1->gnuplot_set_ylabel("bugs fixed"); |
|
1048
|
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
Sets the y axis label. |
|
1050
|
|
|
|
|
|
|
Equivalent to the B command C. |
|
1051
|
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
=head2 gnuplot_set_xrange |
|
1053
|
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
$plot1->gnuplot_set_xrange( left, right ); |
|
1055
|
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
Sets the horizontal range that will be displayed. |
|
1057
|
|
|
|
|
|
|
Equivalent to the B command C. |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=head2 gnuplot_set_yrange |
|
1060
|
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
$plot1->gnuplot_set_yrange( low, high ); |
|
1062
|
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
Sets the vertical range that will be displayed. |
|
1064
|
|
|
|
|
|
|
Equivalent to the B command C. |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
=head2 gnuplot_set_plot_titles |
|
1067
|
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
$plot1->gnuplot_set_plot_titles( @ytitles ); |
|
1069
|
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
Sets the list of titles used in the key for each of the y-coordinate data sets |
|
1071
|
|
|
|
|
|
|
specified in subsequent calls to gnuplot_plot_xy or gnuplot_plot_y commands. |
|
1072
|
|
|
|
|
|
|
This is not equivalent to a complete B command; rather it adds a |
|
1073
|
|
|
|
|
|
|
C clause to each data set specified in a B C command. |
|
1074
|
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
=head2 gnuplot_hardcopy |
|
1076
|
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
C can be used to write a plot into a file or make a printable file |
|
1078
|
|
|
|
|
|
|
by setting/resetting the terminal and the output file: |
|
1079
|
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
$plot1->gnuplot_hardcopy( 'function1.gnuplot.ps', |
|
1081
|
|
|
|
|
|
|
'postscript', |
|
1082
|
|
|
|
|
|
|
'color lw 3' ); |
|
1083
|
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy( \@x, \@y1, \@y2 ); |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
$plot1->gnuplot_restore_terminal(); |
|
1087
|
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
The 1. parameter is a file name, the 2. parameter is a B terminal type, |
|
1089
|
|
|
|
|
|
|
the 3. parameter is a string with additional terminal parameters (optional). |
|
1090
|
|
|
|
|
|
|
The current terminal settings will be saved. |
|
1091
|
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
=head2 gnuplot_restore_terminal |
|
1093
|
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
Restores the saved terminal settings after a call to C. |
|
1095
|
|
|
|
|
|
|
Output will go to C again. |
|
1096
|
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
=head3 Print a plot directly |
|
1098
|
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
A hardcopy can be made with an appropriate output format and a pipe to a |
|
1100
|
|
|
|
|
|
|
printer: |
|
1101
|
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
$plot1->gnuplot_cmd( 'set terminal postscript', |
|
1103
|
|
|
|
|
|
|
'set output " | lpr " ' ); |
|
1104
|
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
$plot1->gnuplot_plot_xy( \@x, \@y1, \@y2 ); |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
$plot1->gnuplot_cmd( 'set output', |
|
1108
|
|
|
|
|
|
|
'set terminal x11' ); |
|
1109
|
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
=head2 gnuplot_get_object_id |
|
1111
|
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
Get the (internal) object number (and the object name): |
|
1113
|
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
$obj_number = $plot1->gnuplot_get_object_id(); |
|
1115
|
|
|
|
|
|
|
($obj_number, $obj_name) = $plot1->gnuplot_get_object_id(); |
|
1116
|
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
The object number is set automatically by the constructor. The object name can |
|
1118
|
|
|
|
|
|
|
be set by the constructor (objectname => 'MyName'). |
|
1119
|
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=head2 gnuplot_get_plotnumber |
|
1121
|
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
Get the (internal) plot number of the B plot: |
|
1123
|
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
$plot_number = $plot1->gnuplot_get_plotnumber() |
|
1125
|
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
The plot number is set automatically by the constructor starting with 1. Each |
|
1127
|
|
|
|
|
|
|
call to |
|
1128
|
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
gnuplot_plot_y |
|
1130
|
|
|
|
|
|
|
gnuplot_plot_xy |
|
1131
|
|
|
|
|
|
|
gnuplot_plot_xy_style |
|
1132
|
|
|
|
|
|
|
gnuplot_plot_many |
|
1133
|
|
|
|
|
|
|
gnuplot_plot_many_style |
|
1134
|
|
|
|
|
|
|
gnuplot_plot_equation |
|
1135
|
|
|
|
|
|
|
gnuplot_plot_3d |
|
1136
|
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
increments this number by 1. This can be used to identify single plots, e.g. |
|
1138
|
|
|
|
|
|
|
with |
|
1139
|
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
$plot->gnuplot_cmd( "set timestamp \"plot number ${plot_number} / %c\"" ); |
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=head1 EXPORTS |
|
1143
|
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
B constructor, short form (see L | GnuplotIF>). |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
1147
|
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
Dialog messages and diagnostic messages start with |
|
1149
|
|
|
|
|
|
|
C< Graphics::GnuplotIF (object NR): ... > . |
|
1150
|
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
C is the number of the corresponding Graphics::GnuplotIF object and output |
|
1152
|
|
|
|
|
|
|
stream. NR counts the objects in the order of their generation. |
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
The gnuplot messages going to STDERR will be redirected to the file |
|
1155
|
|
|
|
|
|
|
C<.gnuplot.PPP.OOO.stderr.log>. PPP is the process number, OOO is the number of |
|
1156
|
|
|
|
|
|
|
the plot object (see L|gnuplot_get_object_id>). |
|
1157
|
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
|
1159
|
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
The environment variable DISPLAY is checked for the display. |
|
1161
|
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
=over 2 |
|
1165
|
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
=item * |
|
1167
|
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
C ( http://sourceforge.net/projects/gnuplot ) must be installed. |
|
1169
|
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
Using Graphics::GnuplotIF on Windows requires having the |
|
1171
|
|
|
|
|
|
|
C version installed. This is the version that emulates a |
|
1172
|
|
|
|
|
|
|
pipe. The Graphics::GnuplotIF object must then be instantiated with |
|
1173
|
|
|
|
|
|
|
the C argument, like so: |
|
1174
|
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
my $plot = Graphics::GnuplotIF -> new(program => 'C:\gnuplot\binaries\gnuplot.exe'); |
|
1176
|
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
A recent compilation of Gnuplot for Windows can be found at |
|
1178
|
|
|
|
|
|
|
SourceForge: L. |
|
1179
|
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
=item * |
|
1181
|
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
The module C is used for error handling. |
|
1183
|
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
=item * |
|
1185
|
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
The module C is used to handle output pipes. Your operating system |
|
1187
|
|
|
|
|
|
|
must support pipes, of course. |
|
1188
|
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
=back |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
1192
|
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
There are no known incompatibilities. |
|
1194
|
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
1196
|
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
$plot1->gnuplot_cmd("pause -1"); # send the gnuplot pause command |
|
1198
|
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
does not work. Use |
|
1200
|
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
$plot1->gnuplot_pause( ); |
|
1202
|
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
There are no known bugs in this module. Please report problems to author. |
|
1204
|
|
|
|
|
|
|
Patches are welcome. |
|
1205
|
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1207
|
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
Dr.-Ing. Fritz Mehner (mehner@fh-swf.de) |
|
1209
|
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
=head1 CREDITS |
|
1211
|
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
Stephen Marshall (smarshall at wsi dot com) contributed C. |
|
1213
|
|
|
|
|
|
|
|
|
1214
|
|
|
|
|
|
|
Georg Bauhaus (bauhaus at futureapps dot de) contributed C. |
|
1215
|
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
Bruce Ravel (bravel at bnl dot gov) contributed C |
|
1217
|
|
|
|
|
|
|
and C, made method calls chainable, and added |
|
1218
|
|
|
|
|
|
|
Windows support. |
|
1219
|
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
1221
|
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
Copyright (C) 2005-2011 by Fritz Mehner |
|
1223
|
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
|
1225
|
|
|
|
|
|
|
the same terms as Perl itself. See perldoc perlartistic. This program is |
|
1226
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
1227
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
1228
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
|
1229
|
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
1231
|
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
C. |
|
1233
|
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
=cut |
|
1235
|
|
|
|
|
|
|
|