help-octave
[Top][All Lists]
Advanced

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

Re: export plot


From: Christoph Dalitz
Subject: Re: export plot
Date: Thu, 27 Nov 2003 11:02:04 +0100

On Wed, 26 Nov 2003 09:29:29 -0600
Joerg Schreiber <address@hidden> wrote:
> 
> how can I export a plot-figure?
> 
Here is a little function "exportplot" that I use for exporting plots.

I would recommend to export to fig-format and postprocess the output
with xfig. This offers more options than sticking to plain gnuplot's
capabilities.

Hope this helps,

Christoph Dalitz

##----------------------------------------------------------------------
##
## (void) exportplot("file.ext")
##
##    exports the last plot as file "file.ext"
##    the extension ".ext" determines the file type and can be
##       .fig   -  xfig file
##       .eps   -  encapsulated postscript
##
function exportplot (filename)

  ## figure out gnuplot terminal type, based on extension
  termtype.fig = "fig color big thickness 2 fontsize 20";
  termtype.eps = "postscript eps color \"Helvetica\" 20";
  n = rindex(filename, ".");
  if (n <= 0) | (n >= length(filename))
        printf("exportplot: extension missing in filename '%s'\n", filename);
        return;
  endif
  ext = substr(filename, n+1);
  eval(sprintf("gplotterm = termtype.%s;", ext), "gplotterm = \"\";");
  if (gplotterm == "")
        printf("exportplot: unsupported extension '%s'\n", ext);
        return;
  endif

  ## export last plot
  eval(sprintf("gset output \"%s\";", filename));
  eval(sprintf("gset term %s;", gplotterm));
  replot;

  ## reset default plotting values
  gset term x11;
  gset output;

endfunction



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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