octave-maintainers
[Top][All Lists]
Advanced

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

Rewritten version of bar.m


From: John W. Eaton
Subject: Rewritten version of bar.m
Date: Tue, 17 Apr 2007 14:14:53 -0400

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?

| 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


reply via email to

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