Codebase list libgraphics-gnuplotif-perl / 70a0347
[svn-upgrade] new version libgraphics-gnuplotif-perl (1.7) Ansgar Burchardt 12 years ago
4 changed file(s) with 48 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
3434 - gnuplot_pause() not working as advertised.
3535 - New constructor argument 'plot_also': write all plot commands to a file, in
3636 addition show the plots.
37
38 1.7 June 3 2011
39 - Windows support (thanks to Bruce Ravel).
00 --- #YAML:1.0
11 name: Graphics-GnuplotIF
2 version: 1.6
2 version: 1.7
33 abstract: A dynamic Perl interface to gnuplot
44 author:
55 - Dr.-Ing. Fritz Mehner <mehner@fh-swf.de>
0 GnuplotIF version 1.6
0 GnuplotIF version 1.7
11 =====================
22
33 GnuplotIF is a simple and easy to use Perl interface to gnuplot. gnuplot is a
1111 # COMPANY: FH Südwestfalen, Iserlohn
1212 # VERSION: see $VERSION below
1313 # 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 $
1515 #===============================================================================
1616
1717 package Graphics::GnuplotIF;
2121 use Carp;
2222 use IO::Handle;
2323
24 our $VERSION = '1.6'; # version number
24 our $VERSION = '1.7'; # version number
2525
2626 use base qw(Exporter);
2727 use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS);
7474 };
7575
7676 #---------------------------------------------------------------------------
77 # warn if there is no graphic display
77 # warn if unix and there is no graphic display
7878 #---------------------------------------------------------------------------
79 if ( ! $ENV{'DISPLAY'} ) {
79 if (($^O ne 'MSWin32') and ($^O ne 'cygwin')) {
80 if ( ! $ENV{'DISPLAY'} ) {
8081 warn "Graphics::GnuplotIF : cannot find environment variable DISPLAY \n"
82 }
8183 }
8284
8385 #=== FUNCTION ================================================================
103105 my ( $class, %args ) = @_;
104106
105107 my $self = {
108 program => 'gnuplot', # something like 'C:\gnuplot\binaries\gnuplot.exe' on Windows
106109 style => 'lines',
107110 title => q{},
108111 xlabel => q{},
139142 # open pipe
140143 #-------------------------------------------------------------------------------
141144 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}"
143146 or die "\n$0 : failed to open pipe to \"gnuplot\" : $!\n";
144147 $self->{__iohandle_pipe}->autoflush(1);
145148 }
749752
750753 =head1 VERSION
751754
752 This documentation refers to Graphics::GnuplotIF version 1.5
755 This documentation refers to Graphics::GnuplotIF version 1.6
753756
754757 =head1 SYNOPSIS
755758
807810 Graphics::GnuplotIF is a simple and easy to use dynamic Perl interface to
808811 B<gnuplot>. B<gnuplot> is a freely available, command-driven graphical display
809812 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>.
811814
812815 This module enables sending display requests asynchronously to B<gnuplot>
813816 through simple Perl subroutine calls.
854857 A few named arguments can be passed as key - value pairs (here shown with
855858 their default values):
856859
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()
872875
873876 These attributes are stored in each object.
874877
888891 the pipe to the B<gnuplot> process belonging to that object. The B<gnuplot>
889892 process will also terminate and remove the graphic output. The termination can
890893 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.
891898
892899 =head2 GnuplotIF
893900
11591166
11601167 C<gnuplot> ( http://sourceforge.net/projects/gnuplot ) must be installed.
11611168
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
11621179 =item *
11631180
11641181 The module C<Carp> is used for error handling.
11951212
11961213 Georg Bauhaus (bauhaus at futureapps dot de) contributed C<gnuplot_plot_xy_style>.
11971214
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.
12001218
12011219 =head1 LICENSE AND COPYRIGHT
12021220
1203 Copyright (C) 2005-2008 by Fritz Mehner
1221 Copyright (C) 2005-2011 by Fritz Mehner
12041222
12051223 This module is free software; you can redistribute it and/or modify it under
12061224 the same terms as Perl itself. See perldoc perlartistic. This program is