Mercurial > hg > octave-terminal
changeset 10952:18b0af0bbd6b
image.m: Fix axis limits for single dimension images, add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 08 Sep 2010 08:17:48 -0400 |
parents | 97b8d462ef11 |
children | 9c0b366583cb |
files | scripts/ChangeLog scripts/image/image.m |
diffstat | 2 files changed, 32 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-09-08 Ben Abbott <bpabbott@mac.com> + + * image/image.m: Fix axis limits for single dimension images, add + demo. + 2010-09-07 David Bateman <dbateman@free.fr> * plot/plotyy.m: Don't add the __plotyy_axes__ property to the
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -120,11 +120,27 @@ ydata = [y(1), y(end)]; c = size (img, 2); - xlim = 0.5 * ((x(end) - x(1)) * c / (c - 1) * [-1, 1] + (x(1) + x(end))); + if (c > 1) + xlim = 0.5 * (diff (xdata) * c / (c - 1) * [-1, 1] + sum (xdata)); + elseif (numel (unique (x)) > 1) + xlim = xdata; + elseif (x(1) != 0) + xlim = [0, x]; + else + xlim = [0, 1]; + endif r = size (img, 1); - ylim = 0.5 * ((y(end) - y(1)) * r / (r - 1) * [-1, 1] + (y(1) + y(end))); - + if (r > 1) + ylim = 0.5 * (diff (ydata) * r / (r - 1) * [-1, 1] + sum (ydata)); + elseif (numel (unique (y)) > 1) + ylim = ydata; + elseif (y(1) != 0) + ylim = [0, y]; + else + ylim = [0, 1]; + endif + ca = gca (); tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, @@ -165,3 +181,11 @@ %! h = image (x, y, img); %! set (h, "cdatamapping", "scaled") +%!demo +%! M = 25; +%! img = 1 ./ rand (5, 11) - 1; +%! x = 10 * sort (rand (1, 9)); +%! y = sort (rand (1, 8)); +%! clf +%! image (x, y, img); +