help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiplot gnu under octave?


From: niles
Subject: Re: multiplot gnu under octave?
Date: Mon, 03 Apr 95 10:34:21 -0400

I figured out how to get gnuplot_eps to work with multiple lines!!!
It's only a 2-3 line change but I'll include the whole thing here
since it's really short. You can set 'skip' equal to the number of
lines on each plot minus one...yes you MUST have the SAME number of
lines on each plot, but one can always plot zeros....and it's better
than nothing!

        Try it!
        Rick Niles.

-----
#!/usr/bin/gawk -f
#
# Allows an array of gnuplot plots to be put on a single page.
#
# To use this file, put its directory in your path.  When you are in
# gnuplot, type
#
#       set terminal postscript eps
#       set output "|gnuplot_eps rows=3 cols=2 > outfile.ps"
#
# and then issue plot commands normally.
# The first plot will go on the upper left of the page.
# You can also specify colorder=1 on the command line before the minus sign
# or the list of files, and the plots will be ordered so that the first
# column is filled up, then the second, etc.  Normally, the first row is
# filled up, then the second, etc.
#
# If you want to put a title at the top of each page, specify 'title="string"'
# somewhere on the command line, e.g.,
#       gnuplot_eps rows=3 cols=2 title="Data to prove I'm right"

#
# Function to move the plot to a particular row and column.  Top = row 1,
# column 1.
#
function move_to_plot(row, col) {
    print "grestore";           # Undo last translation.
    if (row == 1 && col == 1 && title) { # Do we have a title?
        print "/Helvetica findfont 14 scalefont setfont"; # Pick the font.
        print "clippath pathbbox 20 sub exch"; # Get line to put title on.
        print "2 div (" title ") stringwidth pop 2 div sub exch"; # Center the 
title.
        print "moveto (" title ") show"; # Display the title.
    }
    print "gsave";              # Put original graphics state back on the stack
    print col-1 " 7.5 72 mul " cols " div mul"; # Set left edge of plot.
    print rows-row " 10 72 mul " rows " div mul"; # Set bottom edge of plot.
    print "translate";
    printf("%g %g scale\n", 0.1 + 1.15/cols, 0.1 + 2.45/rows); # Adjust size of 
plots.
}

NR == 1 {                       # Can't use BEGIN, because rows/cols on
                                # command line won't be right then.
    gsub(/\(/,"\\(",title);     # Escape special characters in the string.
    gsub(/\)/,"\\)",title);
    gsub(/\\/,"\\\\",title);
    print "%!PS-Adobe-2.0";     # Need header line to make sure it is
                                # recognized as postscript.
    row_idx = col_idx = 1;      # At upper left plot.
    move_to_plot(row_idx, col_idx); # Set up to output this plot.
};

!/showpage/                     # Just echo all ordinary lines.
                                # (This assumes "showpage" is on a line by
                                # itself.)

/showpage/ {                    # End of EPS file?
  if (!skip || count++ >= skip) {
  count = 0;
  if (colorder) {               # Fill up in column order?
      if (++row_idx > rows)     # Time to go to next row?
      {
          row_idx = 1;
          if (++col_idx > cols) # Time to flush page?
          {
              col_idx = 1;
              print "showpage";
          }
      }
  }
  else if (++col_idx > cols)    # Time to go to the next row.
  {
    col_idx = 1;                # Back to left margin.
    if (++row_idx > rows)       # New page?
    {
      row_idx = 1;              # Back to upper row.
      print "showpage"          # Terminate current page.
    }
  }
  move_to_plot(row_idx, col_idx); # Move to appropriate plot.
}
};

END { if (row_idx > 1 || col_idx > 1)   # We will be at first plot if we just
                                        # ejected the last page.
        print "showpage"
    };                          # Terminate the plot.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]