11 | 11 |
# COMPANY: FH Südwestfalen, Iserlohn
|
12 | 12 |
# VERSION: see $VERSION below
|
13 | 13 |
# CREATED: 16.07.2005 13:43:11 CEST
|
14 | |
# REVISION: $Id: GnuplotIF.pm,v 1.16 2011/03/03 20:15:14 mehner Exp $
|
|
14 |
# REVISION: $Id: GnuplotIF.pm,v 1.18 2011/06/03 17:34:08 mehner Exp $
|
15 | 15 |
#===============================================================================
|
16 | 16 |
|
17 | 17 |
package Graphics::GnuplotIF;
|
|
21 | 21 |
use Carp;
|
22 | 22 |
use IO::Handle;
|
23 | 23 |
|
24 | |
our $VERSION = '1.6'; # version number
|
|
24 |
our $VERSION = '1.7'; # version number
|
25 | 25 |
|
26 | 26 |
use base qw(Exporter);
|
27 | 27 |
use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS);
|
|
74 | 74 |
};
|
75 | 75 |
|
76 | 76 |
#---------------------------------------------------------------------------
|
77 | |
# warn if there is no graphic display
|
|
77 |
# warn if unix and there is no graphic display
|
78 | 78 |
#---------------------------------------------------------------------------
|
79 | |
if ( ! $ENV{'DISPLAY'} ) {
|
|
79 |
if (($^O ne 'MSWin32') and ($^O ne 'cygwin')) {
|
|
80 |
if ( ! $ENV{'DISPLAY'} ) {
|
80 | 81 |
warn "Graphics::GnuplotIF : cannot find environment variable DISPLAY \n"
|
|
82 |
}
|
81 | 83 |
}
|
82 | 84 |
|
83 | 85 |
#=== FUNCTION ================================================================
|
|
103 | 105 |
my ( $class, %args ) = @_;
|
104 | 106 |
|
105 | 107 |
my $self = {
|
|
108 |
program => 'gnuplot', # something like 'C:\gnuplot\binaries\gnuplot.exe' on Windows
|
106 | 109 |
style => 'lines',
|
107 | 110 |
title => q{},
|
108 | 111 |
xlabel => q{},
|
|
139 | 142 |
# open pipe
|
140 | 143 |
#-------------------------------------------------------------------------------
|
141 | 144 |
if ( $self->{scriptfile} eq q{} || ( $self->{scriptfile} ne q{} && $self->{plot_also} != 0 ) ) {
|
142 | |
open $self->{__iohandle_pipe}, '|- ', "gnuplot ${persist} 2> $self->{__error_log}"
|
|
145 |
open $self->{__iohandle_pipe}, '|- ', $self->{program}." ${persist} 2> $self->{__error_log}"
|
143 | 146 |
or die "\n$0 : failed to open pipe to \"gnuplot\" : $!\n";
|
144 | 147 |
$self->{__iohandle_pipe}->autoflush(1);
|
145 | 148 |
}
|
|
749 | 752 |
|
750 | 753 |
=head1 VERSION
|
751 | 754 |
|
752 | |
This documentation refers to Graphics::GnuplotIF version 1.5
|
|
755 |
This documentation refers to Graphics::GnuplotIF version 1.6
|
753 | 756 |
|
754 | 757 |
=head1 SYNOPSIS
|
755 | 758 |
|
|
807 | 810 |
Graphics::GnuplotIF is a simple and easy to use dynamic Perl interface to
|
808 | 811 |
B<gnuplot>. B<gnuplot> is a freely available, command-driven graphical display
|
809 | 812 |
tool for Unix. It compiles and works quite well on a number of Unix flavours
|
810 | |
as well as other operating systems.
|
|
813 |
as well as other operating systems, including Windows with C<gnuplot.exe>.
|
811 | 814 |
|
812 | 815 |
This module enables sending display requests asynchronously to B<gnuplot>
|
813 | 816 |
through simple Perl subroutine calls.
|
|
854 | 857 |
A few named arguments can be passed as key - value pairs (here shown with
|
855 | 858 |
their default values):
|
856 | 859 |
|
857 | |
|
858 | |
style => 'lines', # one of the gnuplot line styles (see below)
|
859 | |
title => '', # string
|
860 | |
xlabel => 'x', # string
|
861 | |
ylabel => 'y', # string
|
862 | |
xrange => [], # array reference; autoscaling, if empty
|
863 | |
xrange => [], # array reference; autoscaling, if empty
|
864 | |
plot_titles => [], # array of strings; titles used in the legend
|
865 | |
scriptfile => '', # write all plot commands to the specified file
|
866 | |
plot_also => 0, # write all plot commands to the specified file,
|
867 | |
# in addition show the plots
|
868 | |
persist => 0, # let plot windows survive after gnuplot exits
|
869 | |
# 0 : close / 1 : survive
|
870 | |
objectname => '', # an optional name for the object
|
871 | |
silent_pause => 1, # 0 suppress message from gnuplot_pause()
|
|
860 |
program => 'gnuplot' # fully qualified name of the Gnuplot executable
|
|
861 |
style => 'lines', # one of the gnuplot line styles (see below)
|
|
862 |
title => '', # string
|
|
863 |
xlabel => 'x', # string
|
|
864 |
ylabel => 'y', # string
|
|
865 |
xrange => [], # array reference; autoscaling, if empty
|
|
866 |
xrange => [], # array reference; autoscaling, if empty
|
|
867 |
plot_titles => [], # array of strings; titles used in the legend
|
|
868 |
scriptfile => '', # write all plot commands to the specified file
|
|
869 |
plot_also => 0, # write all plot commands to the specified file,
|
|
870 |
# in addition show the plots
|
|
871 |
persist => 0, # let plot windows survive after gnuplot exits
|
|
872 |
# 0 : close / 1 : survive
|
|
873 |
objectname => '', # an optional name for the object
|
|
874 |
silent_pause => 1, # 0 suppress message from gnuplot_pause()
|
872 | 875 |
|
873 | 876 |
These attributes are stored in each object.
|
874 | 877 |
|
|
888 | 891 |
the pipe to the B<gnuplot> process belonging to that object. The B<gnuplot>
|
889 | 892 |
process will also terminate and remove the graphic output. The termination can
|
890 | 893 |
be controlled by the method L<C<gnuplot_pause> | gnuplot_pause> .
|
|
894 |
|
|
895 |
The program argument is provided to allow Graphics::GnuplotIF to be
|
|
896 |
used with Gnuplot on Windows using C<gnuplot.exe>, a compilation
|
|
897 |
which includes code that emulates a unix pipe.
|
891 | 898 |
|
892 | 899 |
=head2 GnuplotIF
|
893 | 900 |
|
|
1159 | 1166 |
|
1160 | 1167 |
C<gnuplot> ( http://sourceforge.net/projects/gnuplot ) must be installed.
|
1161 | 1168 |
|
|
1169 |
Using Graphics::GnuplotIF on Windows requires having the
|
|
1170 |
C<gnuplot.exe> version installed. This is the version that emulates a
|
|
1171 |
pipe. The Graphics::GnuplotIF object must then be instantiated with
|
|
1172 |
the C<program> argument, like so:
|
|
1173 |
|
|
1174 |
my $plot = Graphics::GnuplotIF -> new(program => 'C:\gnuplot\binaries\gnuplot.exe');
|
|
1175 |
|
|
1176 |
A recent compilation of Gnuplot for Windows can be found at
|
|
1177 |
SourceForge: L<http://sourceforge.net/projects/gnuplot/files/gnuplot/>.
|
|
1178 |
|
1162 | 1179 |
=item *
|
1163 | 1180 |
|
1164 | 1181 |
The module C<Carp> is used for error handling.
|
|
1195 | 1212 |
|
1196 | 1213 |
Georg Bauhaus (bauhaus at futureapps dot de) contributed C<gnuplot_plot_xy_style>.
|
1197 | 1214 |
|
1198 | |
Bruce Ravel (bravel at bnl dot gov) contributed C<gnuplot_plot_many> and
|
1199 | |
C<gnuplot_plot_many_style> and made method calls chainable.
|
|
1215 |
Bruce Ravel (bravel at bnl dot gov) contributed C<gnuplot_plot_many>
|
|
1216 |
and C<gnuplot_plot_many_style>, made method calls chainable, and added
|
|
1217 |
Windows support.
|
1200 | 1218 |
|
1201 | 1219 |
=head1 LICENSE AND COPYRIGHT
|
1202 | 1220 |
|
1203 | |
Copyright (C) 2005-2008 by Fritz Mehner
|
|
1221 |
Copyright (C) 2005-2011 by Fritz Mehner
|
1204 | 1222 |
|
1205 | 1223 |
This module is free software; you can redistribute it and/or modify it under
|
1206 | 1224 |
the same terms as Perl itself. See perldoc perlartistic. This program is
|