help-octave
[Top][All Lists]
Advanced

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

Re: Newbie Questions


From: John B. Thoo
Subject: Re: Newbie Questions
Date: Tue, 1 Apr 2003 22:58:18 -0800

On Tuesday, April 1, 2003, at 10:02 PM, A S Hodel wrote:

That's not the error I'd have expected. Without the quotes, I'd expect to see:

octave:1> sombrero(20);
octave:2> printpng(sine,medium)
error: `sine' undefined near line 2 column 10
error: evaluating argument list element number 1

What happens if you copy printpng.m to your current working directory?

After copying "printpng.m" to the current working directory, I get

octave:7> sombrero (20);
octave:8> printpng (sine, medium)
error: `sine' undefined near line 8 column 11
error: evaluating argument list element number 1
octave:8>


What do you get if you type in

which printpng
which printps
which printeps
?

I get

octave:8> which printpng
printpng is the user-defined function from the file
/Users/jbthoo/claw/applications/euler/1d/hump13/printpng.m
octave:9> pwd
/Users/jbthoo/claw/applications/euler/1d/hump13
octave:10>

(I haven't yet copied the functions "printps" or "printeps" to their own files.)

Thanks for thinking about this.

---John.


On Tuesday, April 1, 2003, at 09:38 PM, John B. Thoo wrote:

Hi. I'm using GNU Octave, version 2.1.40 (powerpc-apple-darwin6.3) installed with Fink on Mac OS X 10.2.5.

Some time ago, A.S. Hodel kindly provided the functions (below) for "printing" to different file formats. Tonight, I copied the function "printpng" to a file I named "printpng.m" that I put in the directory '/sw/lib/octave/site/m'; I then set permissions on the "printpng.m" to '-rwxr-xr-x'. But when I try to use "printpng", I get the following error.

octave:1> x = 0:0.1:2*pi; plot (x, sin (x))
octave:2> printpng (sine, medium)
error: `printpng' undefined near line 2 column 1
octave:2>

What am I doing wrong?  Thanks.

---John.


On Wednesday, January 15, 2003, at 06:50 AM, A S Hodel wrote:


On Wednesday, January 15, 2003, at 06:59 AM, Pablo Barrera wrote:

Elijah P Newren wrote:


You must use the gset command. With this command you can pass directly to gnuplot any "set" command. In order to remove the legend you only need

gset nokey


gset is also usefull for printing a image in postcript.

gset terminal postcript
gset output "output_file.ps"
plot anything

here's a few scripts I often use for "printing." printeps is especially useful if you use LaTeX for document preparation.

These scripts will not work if you use subplot( ... ) to generate multiple plots in a single window. You will have to use gset commands before using gnuplots multiplot capability.

function printps(filename)
% function printps(filename)
% replot screen plot to a file
% inputs:
%   filename: string:
% no argument checking done - this means YOU mark!

  gset terminal postscript color
  eval(sprintf("gset output '%s'", filename));
  replot
  gset terminal x11
endfunction


function printpng(filename,pngsiz,fn)
% function printpng(filename,pngsiz,fn)
% replot screen plot to a file
%
% inputs:
%   filename: string:
%   pngsiz: "small", "medium" (default), or "large"
%   fn: figure number to convert to png form (default: 0)
% no argument checking done

  if(nargin < 2)
    pngsiz = "small";
  elseif(isempty(pngsiz))
    pngsiz = "small";
  endif
  if(nargin < 3)
    fn =0;
  endif
  figure(fn);
  cmd = (sprintf(" gset terminal png %s color",pngsiz));
  eval(cmd);
  cmd = (sprintf("gset output '%s'", filename));
  eval(cmd);
  replot
  closeplot();
endfunction

function printeps(filename)
% function printeps(filename)
% replot screen plot to a file
% inputs:
%   filename: string:
% no argument checking done - this means YOU mark!

  gset terminal postscript eps color
  eval(sprintf("gset output '%s'", filename));
  replot
  #gset terminal x11
  closeplot
endfunction



A. S. Hodel, Assoc. Prof, Dept. Elect & Comp Eng, Auburn University, AL 36849-5201 (334) 844-1854 200 Broun Hall address@hidden http://www.eng.auburn.edu/~scotte



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




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






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