Mercurial > hg > octave-nkf
changeset 17734:64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
* scripts/image/imshow.m: Add support for "xdata" and "ydata" options, make
option parser case insensitive.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sat, 06 Apr 2013 13:56:21 +0200 |
parents | 8ad59bef27b5 |
children | 6a2e483125dd |
files | scripts/image/imshow.m |
diffstat | 1 files changed, 29 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -45,6 +45,19 @@ ## @table @asis ## @item @qcode{"displayrange"} ## @var{value1} is the display range as described above. +## +## @item "xdata" +## If @var{value1} is a two element vector, it must contain horizontal axis +## limits in the form [xmin xmax]; Otherwise @var{value1} must be a +## vector and only the first and last elements will be used for xmin and +## xmax respectively. +## +## @item "ydata" +## If @var{value1} is a two element vector, it must contain vertical axis +## limits in the form [ymin ymax]; Otherwise @var{value1} must be a +## vector and only the first and last elements will be used for ymin and +## ymax respectively. +## ## @end table ## ## The optional return value @var{h} is a graphics handle to the image. @@ -64,6 +77,7 @@ display_range = NA; true_color = false; indexed = false; + xdata = ydata = []; ## Get the image. if (ischar (im)) @@ -105,9 +119,21 @@ error ("imshow: argument number %d is invalid", narg+1); endif elseif (ischar (arg)) - switch (arg) + switch (tolower (arg)) case "displayrange"; display_range = varargin{narg++}; + case "xdata"; + xdata = varargin{narg++}; + if (! isvector (xdata)) + error ("imshow: xdata must be a vector") + endif + xdata = [xdata(1) xdata(end)]; + case "ydata"; + ydata = varargin{narg++}; + if (isvector (xdata)) + error ("imshow: expect a vector for ydata") + endif + ydata = [ydata(1) ydata(end)]; case {"truesize", "initialmagnification"} warning ("image: zoom argument ignored -- use GUI features"); otherwise @@ -161,9 +187,9 @@ endif if (true_color || indexed) - tmp = image ([], [], im); + tmp = image (xdata, ydata, im); else - tmp = image (im); + tmp = image (xdata, ydata, im); set (tmp, "cdatamapping", "scaled"); ## The backend is responsible for scaling to clim if necessary. set (gca (), "clim", display_range);