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