multiplot issue

Help
zampala
2007-04-05
2013-02-10
  • zampala

    zampala - 2007-04-05

    Hi,
    I have k=n+m measurement files in a dir named a1_1.txt, a1_2.txt, ..., a1_n.txt and a2_1.txt, a2_1.txt, ..., a1_m.txt, with n not necessarily equal to m.
    I would like to write a script that plots in two different graphs all the "a1" and the "a2" data files (well, creating two eps files would be better).
    I can do it with something like
    gnuplot# plot "a1_1.txt", "a1_2.txt", ...
    but for n and m greater then 10 it becomes silly. I had in mind a script that scans a specific folder searching "a1" files and plots them all in one graph, then the same for "a2" files. How can implement a for loop like

    for i in *
    plot "a1_$1.txt"   ??

    I would be able to do it within bash script if I only was on a linux box, but here at work I have to use win. Hope to have made myself clear...
    Any ideas?
    thanks in advance,

    mirko

     
    • Hans-Bernhard Broeker

      Having to use Windows as the OS doesn't have to deprive you of the option of using Linux tools.  Cygwin exists.

      Maybe your plot could be as simple as

        plot "< cat a1*.txt", "< cat a2*.txt"

       
    • Sammy Lightfood

      Sammy Lightfood - 2007-04-13

      I use for problems like this simple perl scripts. Perl is available for all OS. For example following perl code is doing it:

      opendir DIR, ".";
      @files = readdir DIR;
      closedir DIR;
      $string1 = "plot ";
      $string2 = "plot ";

      foreach $name (@files)
      {
        next unless ($name =~ m/^a[1,2].+\.txt/);
        if ($name =~ m/^a1/) {$string1 .= "\&quot;$name\&quot;,";}
        if ($name =~ m/^a2/) {$string2 .= "\&quot;$name\&quot;,";}
      }
      chop $string1;
      chop $string2;
      open OUT, ">gnuplotfile.plt";
      print OUT $string1."\n";
      print OUT $string2."\n";
      close OUT;

      Of course shorter code is possible :)

      Best regards,
      Sammy :)

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks