anthonyt has asked for the wisdom of the Perl Monks concerning the following question:

I can get both "func" and "points" to create a plot file under Linux, but in Windows the "points" output file is empty while the "func" output file looks right. Uncomment the "func" line and comment the points line. I included the "gnuplot" path for Windows. Here is my test code:
#!/usr/bin/perl use warnings; use Chart::Gnuplot; my $chart = Chart::Gnuplot->new( gnuplot => 'e:\apps\gnuplot\bin\wgnuplot.exe', output => 'testfile.gif', terminal => "gif transparent", ); my @xy = ( [1.1, -3], [1.2, -2], [3.5, 0] ); my $dataSet = Chart::Gnuplot::DataSet->new( points => \@xy # func => "20*sin(x)" ); $chart->plot2d($dataSet);
Also, is there a way to find out if gnuplot is complaining about something through Chart::Gnuplot ?

Replies are listed 'Best First'.
Re: Chart::Gnuplot dataset under Windows XP empty GIF
by toolic (Bishop) on Feb 15, 2009 at 02:26 UTC
    is there a way to find out if gnuplot is complaining about something through Chart::Gnuplot ?
    You could make a copy of the source code of Chart::Gnuplot and edit the code to check the return value of the call to system in sub _execute:
    if (system("$gnuplot $self->{_script}")) { die "Error: $gnuplot $self->{_script}: $?" }
      Thanks, that brings me a step closer. I am now getting:
      Error: e:\apps\gnuplot\bin\wgnuplot.exe E:\tmp\xhxbHAg9oN\plot: 256 at + C:/strawberry/perl/site/lib/Chart/Gnuplot.pm line 841.
      I'm not sure what the 256 is yet, but there are many temporary directories and files created and destroyed along the way. I can break the program at various points to see what is happening.

      Note: I used "set TMP=e:\tmp" to override placing the temporary files deep in my docs and settings folder.

      Note: Strawberry perl stores copies of its CPAN modules in three places, using Windows "Find" revealed C:\strawberry\perl\site\lib\Chart\Gnuplot.pm to be the working version.
        There seems a bug in the block "Data in points" in the subroutine _thaw. Please try to replace the lines
        my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); my $fileTmp = "$dirTmp/data";
        and by the following line
        my $fileTmp = $self->{_data};
Re: Chart::Gnuplot dataset under Windows XP empty GIF
by anthonyt (Novice) on Feb 16, 2009 at 15:38 UTC
    The problem turns out to be that the string in the plot file used double quotes around the data file name, like:
        plot "E:\tmp\xxxx\data" title ""

    When I tried that directly in gnuplot, the complaint was:
    warning: Skipping unreadable file "E:tmpxxxxdata" No data in plot
    For Windows, it appears that single quotes are needed to allow the single slash character \ to go through. I changed the line around 1381 from:
        $string = "\"$fileTmp\"";
    to
        $string = "'$fileTmp'";

    The previous issue of the temp files existing was me not realizing that they all get destroyed on exit, I had to insert a "sleep 30" command in the module after the plot was executed so I could see what the plot and data files looked like before they were removed. Gnuplot errors were not printed to the DOS window.