Easy plotting with Gnuplot

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Easy plotting with Gnuplot

David Pedersen
Is there a conventient way to plot graphs using Gnuplot from octave
(like MATLAB).  I've been changing the terminal setting and outputing
postscript to the printer. I would like to easily generate plots which
are scaled on the output page.

Dave Pedersen


Reply | Threaded
Open this post in threaded view
|

RE: Easy plotting with Gnuplot

Ted.Harding
On 16-Aug-98 David Pedersen wrote:
> Is there a conventient way to plot graphs using Gnuplot from octave
> (like MATLAB).  I've been changing the terminal setting and outputing
> postscript to the printer. I would like to easily generate plots which
> are scaled on the output page.

The best way to have proper control over the printed size of plots from gnuplot
is to output them as PostScript files, and import these into a document. Gnuplot
PS output is Encapsulated PostScript (EPS) which software that understands EPS
can position and scale arbitrarily on the page. Trying to do this within gnuplot
itself is inexact and frustrating.

I use the following two utilities which I wrote a long time ago. There are
things in there which you can alter to taste, possibly by introducing extra
function parameters.

NOTE that they only set up the destination of graphics output, they do not
do any plotting. For that, you first set up the destination and then either
"replot" or a new "plot" command. Also, it is wise to make sure the output is
flushed and closed by switching back and forth.

E.g.
  plot(......)
  printer("Fig1.eps","P");
  replot
  screen
  replot


file printer.m
--------------
function printer(fname,orient)
# printer                -- diverts graphics to printer in PostScript
# printer(fname)         -- diverts graphics to file fname in PostScript
# printer(fname,orient)  -- as for preceding but orient="L" or "P" forces
#                              orientation (default is "L").
#
# ( screen        -- restores graphics output to screen )

if nargin == 0, fname = "|lpr" ;
   gset term postscript landscape "Helvetica" 12
else
   if nargin == 1, gset term postscript landscape "Helvetica" 12
   else
      if strcmp(orient,"P"), set term postscript portrait "Helvetica" 14
      else
         gset term postscript landscape "Helvetica" 12
      endif
   endif
endif

eval(["gset output \"" fname "\""]);
endfunction


file screen.m
-------------
gset terminal x11
gset output

==========================================================================

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[hidden email]>
Date: 16-Aug-98                                       Time: 10:29:40
--------------------------------------------------------------------