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

I'm having an issue that I can't figure out. I wrote a script to parse out several text files and print 3D plots. It works perfectly if I only print one plot. However, when I step up the number of files up to two, it seems to print the same plot twice. When I step up the number of files to 5 or 6. It prints a few correctly, and a few incorrectly. I'm thinking that maybe there is some error in how Perl is opening GNUPlot. Please help!

Below is a my pseudo-code.

$Num_of_Files = 2; #Number of Files being read $Label[0] = "ABC"; $Label[1] = "DEF"; # Files to be read $file[0] = '/u/ABC.asc'; $file[1] = '/u/DEF.asc'; ## Read Files and Create Data for Plotting ## for ($i=0; $i<$Num_of_Files; $i++) { # Jump through each file open(Read, $file[$i]); @Read = <Read>; @Write3D = ""; foreach $part (@Read) { # Visit each text line in turn if ($part =~ /DATA/) { # Lines with Information to include $part =~ s/ /:/g; @Row = split(/:+/, $part); push(@Write3D, "$Row[1]\t"); push(@Write3D, "$Row[2]\t"); push(@Write3D, "$Row[3]\n"); } } writeFile_ref ("Data.txt", \@Write3D); # Creates data file close(Read); ## Opens GNUPlot and Creates Plots ## open(G, "|/usr/local/bin/gnuplot") or die "/usr/local/bin/gnuplot"; print G <<ENDOFHERE set term x11 set title '$Label[$i]' # Title for Graphs set nokey set output '$Label[$i] - PowerUp Seq 3D.png' splot 'Data.txt' using 1:2:3 with lines lw 2 ## 3D Plot ## unset logscale; ENDOFHERE }

Thanks in Advance!

Replies are listed 'Best First'.
Re: Printing Multiple Plots
by zentara (Cardinal) on Jun 19, 2012 at 16:36 UTC
    Just googling for gnuplot multiple plots, it seems that your heredoc could use the line
    #Don't clear the window, very general method: set multiplot

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Printing Multiple Plots
by linuxkid (Sexton) on Jun 19, 2012 at 20:06 UTC

    Have you considered using a CPAN Module, i know there are some to work with GNUPlot, and i have used on once, but i don't normally work with data in this respect, so I don't have much experience.

    --linuxkid


    imrunningoutofideas.co.cc