octave-maintainers
[Top][All Lists]
Advanced

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

Re: Rewritten version of bar.m


From: David Bateman
Subject: Re: Rewritten version of bar.m
Date: Wed, 18 Apr 2007 00:45:29 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

John W. Eaton wrote:
> On 17-Apr-2007, David Bateman wrote:
> 
> | Here is a rewritten version of bar.m for comment. Its not perfect, due
> | to a couple of issues, but it does treat groups and stacks when "y" is a
> | matrix, and is converted to use graphic handles. The matlab version uses
> | a new handle type called a barseries, whereas this version just uses the
> | line type to create the bars. It also returns a graphic handle (or
> | several if y is a matrix) and allows additional properties to be past to
> | the underlying plot command.
> 
> Will it be fairly simple to convert this to create and return a
> barseries object if/when we have them?

converting it to use patches would be trivial. I'm not sure what a
barseries really is..

> 
> | Finally, though I haven't done it barh
> | might be trivially created from this file, by replacing
> | 
> |     varargout{1} = plot (xb, yb, newargs{:});
> | 
> | with
> | 
> |     varargout{1} = plot (yb, xb, newargs{:});
> | 
> | Unfortunately barh can't really be written as
> | 
> | function varargout = barh (varargin)
> |  [xb,yb] = bar(varargin{:});
> |  if (nargout > 1)
> |    varargout{1} = plot (yb,xb);
> |  else
> |    varargout{1} = xb;
> |    varargout{2} = yb;
> |  endif
> | endfunction
> | 
> | as this doesn't correctly treat all of the additional line properties
> | that might be passed to the plot command.
> 
> What about having an internal __bar__ function that does all the real
> work and takes an extra first argument to indicate orientation?
> 
> Then I think bar and barh could be written as
> 
>   function varargout = bar (varargin)
>     if (nargout > 0)
>       varargout = cell (nargout, 1);
>       [varargout{:}] = __bar__ ('vertical', varargin);
>     else
>       __bar__ ('vertical', varargin);
>     endif
>   endfunction
> 
>   function varargout = barh (varargin)
>     if (nargout > 0)
>       varargout = cell (nargout, 1);
>       [varargout{:}] = __bar__ (horizontal', varargin);
>     else
>       __bar__ ('vertical', varargin);
>     endif
>   endfunction
> 
> jwe
> 

That would work as long as you don't mind an additional internal function

D.


reply via email to

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