help-octave
[Top][All Lists]
Advanced

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

Re: plot to file


From: John W. Eaton
Subject: Re: plot to file
Date: Wed, 7 Dec 2005 10:50:52 -0500

On  7-Dec-2005, James R. Phillips wrote:

| If you don't mind using __gnuplot_set__, there is a relatively simple way to
| plot without X. Try something like this:
| 
| =========
| __gnuplot_set__ term push;
| __gnuplot_set__ term postscript eps color;
| __gnuplot_set__ output "/dev/null";
| 
| [commands to make your plot, exclusive of printing]
| 
| __gnuplot_set_output "output_file.eps";
| replot;
| pause(1);
| __gnuplot_set__ term pop;
| __gnuplot_set__ output;
| 
| ========
| The pause seems to be required at times to prevent garbling the output file.
| 
| This approach is very similar to what the print command actually does, if you
| study the code.  It will not work if multiplot mode is invoked in the set of
| plot commands (neither does print).

No, but for simple plots you don't need to set the output to
/dev/null, then a real file followed by replot.  You could just set
the output to the file, execute the plotting commands, then reset the
terminal and output.

This approach should work with multiplots too.  Try this:

  __gnuplot_set__ term push
  __gnuplot_set__ term postscript eps color
  __gnuplot_set__ output "foo.ps"
  subplot (2, 1, 1)
  x = -10:0.1:10;
  plot (x, sin(x))
  subplot (2, 1, 2)
  plot (x, cos(x))
  oneplot ()
  __gnuplot_set__ output
  __gnuplot_set__ term pop

You may have to set automatic_replot = 0 and you'll need to avoid
plotting commands that generate replot commands (things like hold on
followed by additional plot commands) so plot annotations should come
first, followed by the plot command (same as gnuplot expects).

For "handle graphics" in the future, we will want to implement an
invisible attribute so that plots could be created without displaying
them, then printed (this is similar to what you have shown above).
It should also work for multiplots.  That may require changes to
gnuplot if it is used as the backend plotter.

jwe



-------------------------------------------------------------
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]