help-octave
[Top][All Lists]
Advanced

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

Re: xlabel


From: Bob Odom
Subject: Re: xlabel
Date: Sun, 28 Mar 2010 19:17:36 -0700 (PDT)


On Sun, 28 Mar 2010, Henry F. Mollet wrote:

on 3/27/10 7:51 PM, Ben Abbott at address@hidden wrote:

On Mar 27, 2010, at 10:15 PM, Henry F. Mollet wrote:

I'm trying to update old scripts that use gset. I'm using Octave
3.2.2/Gnuplot4.25/AquaTerm on Mac with OS 10.4.11. I've tried the example
given with doc xlabel but have problems with the xlabel and also the
position of the title. Result of example is attached.

I've tried suggestions by Ben in an answer to the same question dated June
29, 2009 but have the same problems with xlabel after changing
defaultposition or changing to x11.
Henry

-3.2.2:28> doc xlabel

File: octave.info,  Node: Plot Annotations,  Next: Multiple Plots on One
Page, \
Prev: Three-Dimensional Plotting,  Up: Plotting Basics

15.1.3 Plot Annotations
-----------------------

You can add titles, axis labels, legends, and arbitrary text to an
existing plot.  For example,

    x = -10:0.1:10;
    plot (x, sin (x));
    title ("sin(x) for x = -10:0.1:10");
    xlabel ("x");
    ylabel ("sin (x)");
    text (pi, 0.7, "arbitrary text");
    legend ("sin (x)");

  The functions `grid' and `box' may also be used to add grid and
border lines to the plot.  By default, the grid is off and the border
lines are on.

Entering one command after the other:

octave-3.2.2:5>      x = -10:0.1:10;
octave-3.2.2:6>      plot (x, sin (x));
octave-3.2.2:7>      title ("sin(x) for x = -10:0.1:10");
octave-3.2.2:8>      xlabel ("x");
error: invalid use of script in index expression
octave-3.2.2:8>      ylabel ("sin (x)");
octave-3.2.2:9>      text (pi, 0.7, "arbitrary text");
octave-3.2.2:10>      legend ("sin (x)");
octave-3.2.2:11>

Suggestion based on answer by Ben to the same question:
octave-3.2.2:19> close all
octave-3.2.2:20> set (0, "defaultaxesposition", [0.13, 0.13, 0.775, 0.795])
octave-3.2.2:21> plot (1:10)
octave-3.2.2:22> xlabel ("my xlabel")
error: invalid use of script in index expression
octave-3.2.2:22> close all
octave-3.2.2:23> setenv ("GNUTERM", "x11")
octave-3.2.2:24> plot (1:10)
octave-3.2.2:25> xlabel ("my xlabel")
error: invalid use of script in index expression
octave-3.2.2:25>

Henry,

So far I've been unable to locate where the error you see originates.

From what you've presented, I infer that something may be wrong with your
xlabel script.

What you do get when you type...

ls(cstrcat('-l ',which('xlabel')))

If the date is more recent than 2009-07-29 then it may have been modified ...
Did you download the Octave binary from SourceForge, or build it from sources
using Fink or MacPorts?

Ben


I have more than one xlabel.m on my computer but I believe my Octave 3.2.2
is using the one associated with it. The file is given below.
Thanks, Henry


I installed the latest version of a binary from Thomas in Germany.
[~] -bash-2.05b 501$ exec
'/Applications/Octave.app/Contents/Resources/bin/octave'
GNU Octave, version 3.2.2
Copyright (C) 2009 John W. Eaton and others.

octave-3.2.2:1> ls(cstrcat('-l ',which('xlabel')))
-rw-r--r--   1 hfm  admin  1720 Jul 25  2009
/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot/xlabel
.m
octave-3.2.2:2>

[~] -bash-2.05b 501$ locate xlabel.m
/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot/xlabel
.m
/Volumes/octave.app.dmg/Octave.app/Contents/Resources/share/octave/3.2.2/m/p
lot/xlabel.m
/usr/local/share/octave/2.1.71/m/plot/xlabel.m
/usr/local/share/octave/2.1.71/site/octave-forge-alternatives/m/graceplot/xl
abel.m

[~] -bash-2.05b 502$ cd
/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot

[/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot]
-bash-2.05b 504$ cat xlabel.m
## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
##               2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {} xlabel (@var{string})
## @deftypefnx {Function File} {} ylabel (@var{string})
## @deftypefnx {Function File} {} zlabel (@var{string})
## @deftypefnx {Function File} {} xlabel (@var{h}, @var{string})
## Specify x, y, and z axis labels for the current figure.  If @var{h} is
## specified then label the axis defined by @var{h}.
## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
## bar, stairs, title}
## @end deftypefn

## Author: jwe

function retval = xlabel (varargin)

 [h, varargin, nargin] = __plt_get_axis_arg__ ("xlabel", varargin{:});

 if (rem (nargin, 2) != 1)
   print_usage ();
 endif

 oldh = gca ();
 unwind_protect
   axes (h);
   tmp = __axis_label__ ("xlabel", varargin{:});
 unwind_protect_cleanup
   axes (oldh);
 end_unwind_protect

 if (nargout > 0)
   retval = tmp;
 endif

endfunction

[/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot]
-bash-2.05b 505$

N.B. Not sure what's going on but I'm making progress. See attached.
Henry
octave-3.2.2:2> plot (1:10)
octave-3.2.2:3> ylabel ("y-label")
octave-3.2.2:4> xlabel ("x-label") % Note no error message
octave-3.2.2:5> close all
octave-3.2.2:6> set (0, "defaultaxesposition", [0.13, 0.13, 0.775, 0.795])
octave-3.2.2:7> plot (1:10)
octave-3.2.2:8> ylabel ("my y-label")
octave-3.2.2:9> xlabel ("my x-label")
octave-3.2.2:10>


Henry,

You should do a 'diff' on the two versions of xlabel.m, and see what the
differences are. The other thing you could do is to temporarily 'mv' the

'/usr/local/share/octave/2.1.71/m/plot/xlabel.m' to anything else like '/usr/local/share/octave/2.1.71/m/plot/xlabel.m.old'

If you do this, be sure to label the moved files so that you don't get
them mixed up.

Then try your example again. If you get a 'file not found' error, then
you will know that it is grabbing the old one.

If you still get the same error, then try using the old version by
'mv'ing the 3.2.2 version to something else like xlabel.m.3.2.2 and
copying the /usr/local/share/octave/2.1.71/m/plot/xlabel.m to the

/Applications/Octave.app/Contents/Resources/share/octave/3.2.2/m/plot/

directory. Then you can try to run your example using the old xlabel.m.

I am no pro at octave, but this is one easy way to see which version it
is accessing.

Bob


reply via email to

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