Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

gnuplot problems

by danambroseUK (Beadle)
on Apr 22, 2004 at 09:49 UTC ( #347284=perlquestion: print w/replies, xml ) Need Help??
danambroseUK has asked for the wisdom of the Perl Monks concerning the following question:

I have a script which has been working fine until last week and i dont know why.
$graph .= <<BLOCK; set terminal png transparent set output "tmp/$random.png" set size 0.9,0.5 set pointsize 0 set xdata time set format x "%a\\n%H:00" set ylabel "Degrees C" set xlabel "Hours" set timefmt "%Y-%m-%d%H:%M:%S" set key below plot\\ BLOCK foreach $i (@inputs){ $graph = $graph . "\"tmp/$random.dat\" using 1:" . $c . " title '$i' w +ith lines,\\\n"; $c++; } $graph = substr($graph, 0, (length($graph)-3)); open (GNUPLOT, "|/usr/bin/gnuplot") or die $!; print GNUPLOT $graph . "\n\n"; close (GNUPLOT);
sample datafile:
set terminal png transparent set output "tmp/854.png" set size 0.9,0.5 set pointsize 0 set xdata time set format x "%a\n%H:00" set ylabel "Degrees C" set xlabel "Hours" set timefmt "%Y-%m-%d%H:%M:%S" set key below plot\ "tmp/854.dat" using 1:2 title 'D4_AVG' with lines
The datafile is made fine, but no graph image file is produced. When i save $graph to file and then paste it to gnuplot on command line - its works fine. Your help would be great! Dan

Replies are listed 'Best First'.
Re: gnuplot problems
by Abigail-II (Bishop) on Apr 22, 2004 at 10:47 UTC
    I think the problem is that you remove the final newline - and gnuplot uses newlines to terminate commands. If you cut-and-paste, such an action will introduce a terminating newline.

    Abigail

      Surley the \n\n when $graph is printed will keep the required newlines in?

      Ive tried what has been mentioned - but the problem doesnt seem to be resolved.

      The thing is the script has been working fine for months until last week- when it decided not to work anymore!

      Am i opening and printing correctly to GNUPLOT?


      Thanks all,

      Dan
Re: gnuplot problems
by Fletch (Chancellor) on Apr 22, 2004 at 14:28 UTC

    And if you used join you wouldn't have to worry about incorrect trailing seperators.

    $graph .= join( ", \\\n", map qq{"tmp/$random.dat" using 1:$_ title '$inputs[ $_ - 2 ] +' with lines}, 2..$#inputs+2 );

    Update: And of course you'd append a "\n" on the end of that otherwise you're right back where you were stuck before. %/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://347284]
Approved by matija
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-02-26 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (376 votes). Check out past polls.