[Graph-dev] bugfix/change request for Chart-Graph-3.2's Chart/Graph/Gnuplot.pm
Ketan Desai
ketan at rentec.com
Fri Jan 19 07:03:30 PST 2007
Hi, We recently upgraded our installation of Chart-Graph-3.2 and I ran into some problems.
I generally invoke this perl module inside a Perl/Tk application where the user expects to see
a plot on the screen (I use the gnuplot x11 device).
I tracked my problems down and have two changes to request.
1) gnuplot used to be invoked with a '-persist' flag. The latest module seems to have just removed that flag.
I would like to add a switch to allow the user to request that form of invocation.
2) The "output type" option previously could be set to 'undefined' . This is necessary if one does not want to
write to a file. (I chose not to hack an output type of 'x11' because presumably there are other graphical
devices besides x11 that one might choose to use.)
I would like to add this functionality back in.
Below I show the diff of my version of Chart/Graph/Gnuplot.pm and our installed version (which came from Chart-Graph-3.2).
Thanks for all your efforts, this module is very useful.
-K
*** <loc>/Chart/Graph/Gnuplot.pm 2007-01-10 12:09:40.723747000 -0500
--- /usr/local/products/perl/5.8.8/lib/site_perl/5.8.8/Chart/Graph/Gnuplot.pm 2006-06-07 17:09:33.000000000 -0400
***************
*** 63,69 ****
# these variables hold default options for gnuplot
my %def_gnu_global_opts = (
"title" => "untitled",
- "persist" => 0,
"output type" => "png",
"output file" => "untitled-gnuplot.png",
"x-axis label" => "x-axis",
--- 63,68 ----
***************
*** 116,122 ****
sub gnuplot {
my ($user_global_opts_ref, @data_sets) = @_;
my (%data_opts, %global_opts,);
! my ($plottype, $output_file, $plot_file, $output_type, $data_set_ref, $qPersist);
# create a new filehandle to be used throughout package
my $handle = new FileHandle;
--- 115,121 ----
sub gnuplot {
my ($user_global_opts_ref, @data_sets) = @_;
my (%data_opts, %global_opts,);
! my ($plottype, $output_file, $plot_file, $output_type, $data_set_ref);
# create a new filehandle to be used throughout package
my $handle = new FileHandle;
***************
*** 358,364 ****
$output_file = $value;
}
! if ($key eq "output type" and defined $value) {
if (!($value =~ /^(pbm|gif|tgif|png|svg|eps(:? .*)?)$/)) {
carp "invalid output type: $value";
$handle->close();
--- 357,363 ----
$output_file = $value;
}
! if ($key eq "output type") {
if (!($value =~ /^(pbm|gif|tgif|png|svg|eps(:? .*)?)$/)) {
carp "invalid output type: $value";
$handle->close();
***************
*** 367,376 ****
}
$output_type = $value;
}
-
- if ($key eq 'persist') {
- $qPersist = 1;
- }
}
# create the data file
--- 366,371 ----
***************
*** 441,447 ****
$handle->close();
# gnuplot and convert pbm file to gif
! if (not _exec_gnuplot($command_file, $qPersist)) {
_cleanup_tmpdir();
return 0;
}
--- 436,442 ----
$handle->close();
# gnuplot and convert pbm file to gif
! if (not _exec_gnuplot($command_file)) {
_cleanup_tmpdir();
return 0;
}
***************
*** 765,772 ****
#
sub _exec_gnuplot {
! my ($command_file, $qPersist) = @_;
! my $status = system("$gnuplot", ($qPersist ? '-persist' : ()), "$command_file");
if (not _chk_status($status)) {
return 0;
--- 760,767 ----
#
sub _exec_gnuplot {
! my ($command_file) = @_;
! my $status = system("$gnuplot", "$command_file");
if (not _chk_status($status)) {
return 0;
***************
*** 1047,1053 ****
| | 'svg' or "eps $epsoptions"| |
|'output file' | set your own output file, | 'untitled-gnuplot.png' |
| | undef to output to STDOUT | |
- |'persist' | 0 or 1 | 0 |
|'x-axis label' | set your own label | 'x-axis' |
|'y-axis label' | set your own label | 'y-axis' |
|'x2-axis label' | set your own label | none |
--- 1042,1047 ----
***************
*** 1126,1135 ****
Finally, data can be stored in a file.
- If the plot is to be displayed on a terminal, the "persist" option
- should be used so that I<Gnuplot> will be invoked with "-persist".
- The resultant plot window will persist until the user exits it.
-
=head2 USING GNUPLOT TO READ AND PLOT DATE/TIME DATA DIRECTLY
I<Gnuplot> now has the capability to read date/time data and to create
--- 1120,1125 ----
More information about the Graph-dev
mailing list